DGND3700 V1 Partition Format Drive

From richud.com
Jump to navigation Jump to search


  • Note, you will need firmware 2014-03-14 or newer to do this

Step 1) stop and unmount

(ignore errors - it politely first, then hard kills everything that could access the USB drive)

ACTION=removeall /etc/automount.sh

~ # ACTION=removeall /etc/automount.sh
killall: smbd: no process killed
killall: nmbd: no process killed
killall: smbd: no process killed
killall: nmbd: no process killed
rm: can't remove '/tmp/avahi/services/smb.service': No such file or directory
killall: statd: no process killed
killall: portmap: no process killed
killall: idmapd: no process killed
killall: transmission-daemon: no process killed
killall: transmission-daemon: no process killed
rm: can't remove '/tmp/avahi/services/transmission.service': No such file or directory
killall: minidlnad: no process killed
killall: automatic: no process killed
killall: automatic: no process killed


Step 2) check drive not mounted

There shouldn't be anything mentioning /dev/sda now!

~ # mount 
rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
tmpfs on /tmp type tmpfs (rw)
tmpfs on /media type tmpfs (rw)
tmpfs on /dev type tmpfs (rw)
none on /proc/bus/usb type usbfs (rw)
/dev/mtdblock18 on /tmp/mnt/storage type jffs2 (rw)

Step 3) wipe any existing partition / boot sector

zero out first 100Mb

dd if=/dev/zero of=/dev/sda bs=1M count=100

~ # dd if=/dev/zero of=/dev/sda bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (100.0MB) copied, 4.289913 seconds, 23.3MB/s


Step 4) partition drive

This is a run through of what you press.

fdisk -u -H 255 -S 63 /dev/sda
	n <enter>
	p <enter>
	1 <enter>
	2048 <enter>
	<enter>
	w <enter>


~ # fdisk -u -H 255 -S 63 /dev/sda
Device contains neither a valid DOS partition table, nor Sun, SGI, OSF or GPT disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that the previous content
won't be recoverable.


The number of cylinders for this disk is set to 60801.
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)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (63-976773167, default 63): 2048
Last sector or +size or +sizeM or +sizeK (2048-976773167, default 976773167): Using default value 976773167

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table

Step 6) Check it all looks right

Should see one device, starting at 2048 (or 63), your ending sector will depending on your drives size. e.g. 976773167 / 512 = ~ 500gb

~ # fdisk -lu /dev/sda

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sda1            2048   976773167   488385560  83 Linux

Step 7) Format drive

This is using tuned settings (reduced wasted space), this takes < 1 minute on this 500Gb drive.

mke2fs -t ext3 -i 524288 -I 128 -m 0 -L "DriveLabel" /dev/sda1

~ # mke2fs -t ext3 -i 524288 -I 128 -m 0 -L "my500Gbdrive" /dev/sda1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=my500Gbdrive
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
954112 inodes, 122096390 blocks
0 blocks (0.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
3727 block groups
32768 blocks per group, 32768 fragments per group
256 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

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   

After fiddling around for a while I would suggest using a (-i) value of 6291456, this gave about 120'000 inodes on a 500gb drive which seems plenty.

mke2fs -t ext3 -i 6291456 -I 128 -m 0 -L "DriveLabel" /dev/sda1

Formatting ext4

  • Ext4 is experimental at this kernel release, there are quite a few additional patches added however, but still suggest you use ext3!

To format as ext4 with above example, disabling the 5 options needed;

mke2fs -t ext4 -i 524288 -I 128 -m 0 -L "my500Gbdrive" -O ^extent,^flex_bg,^huge_file,^uninit_bg,^dir_nlink  /dev/sda1

Excess inodes without tuning

I originally created my 320Gb drive with default settings and ended up with *alot* more than is needed, see below

~ # df -i
Filesystem              Inodes      Used Available Use% Mounted on
/dev/root                 1172      1172         0 100% /
tmpfs                    15629       619     15010   4% /tmp
tmpfs                    15629         2     15627   0% /media
tmpfs                    15629       141     15488   1% /dev
/dev/mtdblock18              0         0         0   0% /tmp/mnt/storage
/dev/sda1             19537920       525  19537395   0% /media/WD320Gb

It is using only 525 (drive almost full) with almost 20 million unused!

You can easily change bytes-per-inode (-i) to several million assuming you don't have hundred of thousands of small files on it!

Step 8) create transmissionbt folder

~ # mkdir /tmp/a
~ # mount -t ext3 /dev/sda1 /tmp/a
~ # mkdir -p /tmp/a/transmissionbt/Downloads
~ # chown 1000:1000 /tmp/a/transmissionbt/Downloads
~ # chmod 2775 /tmp/a/transmissionbt/Downloads
~ # ls -la /tmp/a
drwxr-xr-x    4 root     root          4096 Mar 14 19:25 .
drwxrwxrwt   13 root     root           880 Mar 14 19:23 ..
drwx------    2 root     root         16384 Mar 14 19:07 lost+found
drwxr-xr-x    2 root     root          4096 Mar 14 19:25 transmissionbt
~ # reboot
  • Note setting setgid bit along with TBT umask (002) (rw-rw-r--) will mean if the drive is removed and plugged into a pc you should have read/write to files on it as group (user id 1000) has access to everything in Downloads.
  • Note when it reboots it will auto mount as /media/<you drive label>/ and if transmission is set to start on bootup, it should now start.
~ # mount
<SNIP>
/dev/mtdblock18 on /tmp/mnt/storage type jffs2 (rw)
/dev/sda1 on /media/my500Gbdrive type ext3 (rw,noatime,data=ordered)
rpc_pipfs on /tmp/var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
  • Note I run NFS, hence mounts for that appear above too

Comments

blog comments powered by Disqus