Cubie Truck 測試 – Lubuntu 篇 – 擴展 root 分割區

Cubie Truck  Lubuntu Desktop 硬碟分割
$ sudo fdisk -l

Disk /dev/nand: 15.9 GB, 15938355200 bytes
255 heads, 63 sectors/track, 1937 cylinders, total 31129600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/nand doesn’t contain a valid partition table

Disk /dev/nanda: 67 MB, 67108864 bytes
255 heads, 63 sectors/track, 8 cylinders, total 131072 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

     Device Boot      Start         End      Blocks   Id  System

Disk /dev/nandb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders, total 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/nandb doesn’t contain a valid partition table

Disk /dev/nandc: 13.7 GB, 13706985472 bytes
255 heads, 63 sectors/track, 1666 cylinders, total 26771456 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xffffffff

Disk /dev/nandc doesn’t contain a valid partition table[@more@]/dev/nanda 是系統開機分割區
/dev/nandb 是 /root 分割區
/dev/nandc 是還沒使用的區域

參考網頁:
Cubietruck-Resize NAND | www.maruscha.org
cubieboard nand 重新分区扩容 – 我喜欢智能化 – 博客频道 – CSDN.NET

查看 Nand 硬碟分割表資訊
$ sudo nand-part -f a20 /dev/nand
check partition table copy 0: mbr: version 0x00000200, magic softw411
OK
check partition table copy 1: mbr: version 0x00000200, magic softw411
OK
check partition table copy 2: mbr: version 0x00000200, magic softw411
OK
check partition table copy 3: mbr: version 0x00000200, magic softw411
OK
mbr: version 0x00000200, magic softw411
3 partitions
partition  1: class =         DISK, name =   bootloader, partition start =    32768, partition size =   131072 user_type=0
partition  2: class =         DISK, name =       rootfs, partition start =   163840, partition size =  4194304 user_type=0
partition  3: class =         DISK, name =        UDISK, partition start =  4358144, partition size = 26574848 user_type=0

綠色是分割區的名字,粉紅色是分割區的起始位置,橘色是分割區的大小
以 root 分割為例
它的大小是 size =4194304  ; 4194304/1024/2=2048 = 2G
UDISK 是還未用到的區域,也就是 root 分割區要擴展的區域
如果要把全部的空間用完,root 分割區的大小 = 4194304 + 26574848 = 30769152

進行設定
$ sudo nand-part -f a20 /dev/nand 32768 ‘boot 131072’ ‘rootfs 30769152’  
check partition table copy 0: mbr: version 0x00000200, magic softw411
OK
check partition table copy 1: mbr: version 0x00000200, magic softw411
OK
check partition table copy 2: mbr: version 0x00000200, magic softw411
OK
check partition table copy 3: mbr: version 0x00000200, magic softw411
OK
mbr: version 0x00000200, magic softw411
3 partitions
partition  1: class =         DISK, name =   bootloader, partition start =    32768, partition size =   131072 user_type=0
partition  2: class =         DISK, name =       rootfs, partition start =   163840, partition size =  4194304 user_type=0
partition  3: class =         DISK, name =        UDISK, partition start =  4358144, partition size = 26574848 user_type=0
check partition table copy 0: mbr: version 0x00000200, magic softw411
check partition table copy 1: mbr: version 0x00000200, magic softw411
check partition table copy 2: mbr: version 0x00000200, magic softw411
check partition table copy 3: mbr: version 0x00000200, magic softw411

ready to write new partition tables:
mbr: version 0x00000200, magic softw411
2 partitions
partition  1: class =         DISK, name =         boot, partition start =    32768, partition size =   131072 user_type=0
partition  2: class =         DISK, name =       rootfs, partition start =   163840, partition size = 30769152 user_type=0

write new partition tables? (Y/N)
y
Failed rereading partition table: Device or resource busy

verifying new partition tables:
check partition table copy 0: mbr: version 0x00000200, magic softw411
OK
check partition table copy 1: mbr: version 0x00000200, magic softw411
OK
check partition table copy 2: mbr: version 0x00000200, magic softw411
OK
check partition table copy 3: mbr: version 0x00000200, magic softw411
OK
mbr: version 0x00000200, magic softw411
2 partitions
partition  1: class =         DISK, name =         boot, partition start =    32768, partition size =   131072 user_type=0
partition  2: class =         DISK, name =       rootfs, partition start =   163840, partition size = 30769152 user_type=0
rereading partition table… returned -1

重新啟動電腦
$ sudo reboot

重新設定 /dev/nandb 分割區大小
$ sudo resize2fs /dev/nandb
resize2fs 1.42.5 (29-Jul-2012)
Filesystem at /dev/nandb is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/nandb is now 3870720 blocks long.

原本 /root 分割區的大小
$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       2.0G 1020M  894M  54% /
devtmpfs        889M  4.0K  889M   1% /dev
tmpfs            20M  224K   20M   2% /tmp
none            197M  220K  197M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            985M  132K  985M   1% /run/shm
none            100M   12K  100M   1% /run/user

擴展 /root 分割區後的大小
$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        15G 1021M   13G   8% /
devtmpfs        889M  4.0K  889M   1% /dev
tmpfs            20M  4.0K   20M   1% /tmp
none            197M  212K  197M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            985M     0  985M   0% /run/shm
none            100M   12K  100M   1% /run/user