因為 Ubuntu root 分割區的大小實在有些小,稍微安裝一下套件就快滿了!
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 1.8G 1.5G 199M 89% /
devtmpfs 889M 4.0K 889M 1% /dev
none 197M 552K 197M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 985M 172K 985M 1% /run/shm
但在 Ubuntu Desktop 似乎沒有提供 nand-part 這一個指令
$ sudo nand-part
sudo: nand-part: command not found
[@more@]安裝編譯 nand-part 所需的套件
$ sudo apt-get install libusb-1.0-0-dev
下載 sunxi-tools
$ git clone https://github.com/linux-sunxi/sunxi-tools
Cloning into ‘sunxi-tools’…
remote: Counting objects: 1075, done.
remote: Total 1075 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (1075/1075), 368.20 KiB | 156 KiB/s, done.
Resolving deltas: 100% (577/577), done.
切換目錄
$ cd sunxi-tools
進行編譯
$ make
將 nand-part 複製到 /sbin 目錄
$ sudo cp nand-part /sbin
列出 Nand Flash 的分割區狀態
$ 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 = 6291456 user_type=0
partition 3: class = DISK, name = UDISK, partition start = 6455296, partition size = 24477696 user_type=0
綠色是分割區的名字,粉紅色是分割區的起始位置,橘色是分割區的大小
UDISK 是還未用到的區域,也就是 root 分割區要擴展的區域
擴展之後 /dev/nandb 的大小 6291456+24477696 = 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 = 6291456 user_type=0
partition 3: class = DISK, name = UDISK, partition start = 6455296, partition size = 24477696 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
原本的分割區大小
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 1.8G 1.5G 199M 89% /
devtmpfs 889M 4.0K 889M 1% /dev
none 197M 552K 197M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 985M 172K 985M 1% /run/shm
重新設定 /dev/nandb 分割區大小
$ sudo resize2fs /dev/nandb
resize2fs 1.42 (29-Nov-2011)
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.
之後的大小
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 15G 1.6G 13G 12% /
devtmpfs 889M 4.0K 889M 1% /dev
none 197M 536K 197M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 985M 76K 985M 1% /run/shm
列出 Nand Flash 目前的分割區狀態
$ 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
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
不過重新分割的過程中,出現 resize2fs: Permission denied to resize filesystem 的錯誤訊息,重試了很多次還是無法解決,後來重新燒錄 Nash Flash Image,再做一次就正常了!
$ sudo resize2fs /dev/nandb
resize2fs 1.42 (29-Nov-2011)
Filesystem at /dev/nandb is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
resize2fs: Permission denied to resize filesystem