Friday, June 10, 2011

Format a USB disk with ext3 in Red Hat style systems.

We have some Red Hat boxes that do environmental effects on some of the motion pictures we do.  These guys need to archive some of their stuff onto USB disks so they can transport them or give them to clients, etc.  The problem is that they usually come formatted with FAT32 or something, and the files can be greatly in excess of 2.0GB.  So we put ext3 on.

First, see if the USB disk mounted itself.  Sometimes Red Hat does this.  Use df or mount to see if it's there.
[root@discreet ]# df

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda3            151668928  43941540 100023016  31% /
/dev/sda1               101086     13285     82582  14% /boot
none                   3928520        16   3928504   1% /dev/shm
/dev/sdb1            721075720     70584 684376536   1% /mnt/usbdisk1
Unmount /mnt/usbdisk1.
[root@discreet ]# umount /mnt/usbdisk1
then fdisk it (must be root!)
 [root@discreet ]# /sbin/fdisk /dev/sdb

The number of cylinders for this disk is set to 91201.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Input a p to list current partitions.
Command (m for help): p
Disk /dev/sdb: 750.1 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1       91201   732572001    c  W95 FAT32 (LBA)  ### FAT DOES NOT ALLOW >2GB FILES
Delete the FAT32 partition with d.
Command (m for help): d
Selected partition 1


Do another p to display the partition list after you have deleted partition 1.
Command (m for help): p       

Disk /dev/sdb: 750.1 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
We're going to hit n for new partition.
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p           ###### P FOR PRIMARY PARTITION


Partition number (1-4): 1
First cylinder (1-91201, default 1):
Using default value 1       ##### PRESS ENTER FOR CYLINDER 1 TO BE START OF PARTITION
Last cylinder or +size or +sizeM or +sizeK (1-91201, default 91201):   #### JUST PRESS ENTER FOR DEFAULT PARTITION TO TAKE UP WHOLE DRIVE
Using default value 91201

Print the partition table one more time to make sure it's ext3
Command (m for help): p      

Disk /dev/sdb: 750.1 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       91201   732572001   83  Linux  

Write and quit with wq.
Command (m for help): wq               ####### W FOR WRITE, Q FOR QUIT
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Make the new file system.

[root@discreet ]# /sbin/mkfs /dev/sdb1

mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
91586560 inodes, 183143000 blocks
9157150 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
5590 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000
Writing inode tables: done
Writing superblocks and filesystem accounting information: done

Mount your new partition where you like and copy large files to it.

No comments:

Post a Comment