by RobMeades » Sat Feb 14, 2015 10:44 am
That's the method I used but the scenario I'm afraid of is when I make a backup copy of this image (SD card size 15564799) using dd and want to put it on an SD card which happens to have, say, only 15564700 sectors available then if any files used sectors in the 15564700 to 15564799 region they would be corrupted. Given that every SD card is a different size it would be a nightmare to make a backup that could ever be used reliably on any other SD card and impossible to keep two or more SD cards aligned unless they happened to be exactly the same size. Hence I want to be in control of the maximum file system size.
I tried the procedure you point to but entering 15499999 as the last sector however that SD card did not boot in the Pi either.
What am I missing?
Rob
P.S. to prove it, here's a log of my terminal activities when running the defined procedure but with a max size of 15499999 sectors:
$this->bbcode_second_pass_code('', 'ubuntu@ubuntu:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/cow 7.8G 59M 7.7G 1% /
udev 7.7G 4.0K 7.7G 1% /dev
tmpfs 1.6G 1.5M 1.6G 1% /run
/dev/sdc1 15G 985M 14G 7% /cdrom
/dev/loop0 939M 939M 0 100% /rofs
none 4.0K 0 4.0K 0% /sys/fs/cgroup
tmpfs 7.8G 4.0K 7.8G 1% /tmp
none 5.0M 0 5.0M 0% /run/lock
none 7.8G 76K 7.8G 1% /run/shm
none 100M 56K 100M 1% /run/user
/dev/sdb1 932G 812G 121G 88% /media/ubuntu/Elements
/dev/sde2 7.1G 550M 6.2G 9% /media/ubuntu/f00ea051-3e0a-4fed-b809-85df653493e1
/dev/sde1 100M 12M 88M 12% /media/ubuntu/8B01-7D22
ubuntu@ubuntu:~$ sudo su
root@ubuntu:/home/ubuntu# fdisk /dev/sde
Command (m for help): p
Disk /dev/sde: 7969 MB, 7969177600 bytes
246 heads, 62 sectors/track, 1020 cylinders, total 15564800 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: 0xe353cd08
Device Boot Start End Blocks Id System
/dev/sde1 2048 206847 102400 c W95 FAT32 (LBA)
/dev/sde2 206848 15564799 7678976 83 Linux
Command (m for help): o
Building a new DOS disklabel with disk identifier 0xe687e25e.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): p
Disk /dev/sde: 7969 MB, 7969177600 bytes
246 heads, 62 sectors/track, 1020 cylinders, total 15564800 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: 0xe687e25e
Device Boot Start End Blocks Id System
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-15564799, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-15564799, default 15564799): +100M
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): c
Changed system type of partition 1 to c (W95 FAT32 (LBA))
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
Partition number (1-4, default 2): 2
First sector (206848-15564799, default 206848):
Using default value 206848
Last sector, +sectors or +size{K,M,G} (206848-15564799, default 15564799): 15499999
Command (m for help): p
Disk /dev/sde: 7969 MB, 7969177600 bytes
246 heads, 62 sectors/track, 1020 cylinders, total 15564800 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: 0xe687e25e
Device Boot Start End Blocks Id System
/dev/sde1 2048 206847 102400 c W95 FAT32 (LBA)
/dev/sde2 206848 15499999 7646576 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.
root@ubuntu:/home/ubuntu# mkfs.vfat /dev/sde1
mkfs.fat 3.0.26 (2014-03-07)
mkfs.vfat: /dev/sde1 contains a mounted filesystem.
root@ubuntu:/home/ubuntu# umount /dev/sde1
root@ubuntu:/home/ubuntu# umount /dev/sde2
root@ubuntu:/home/ubuntu# mkfs.vfat /dev/sde1
mkfs.fat 3.0.26 (2014-03-07)
root@ubuntu:/home/ubuntu# mkdir boot
root@ubuntu:/home/ubuntu# mount /dev/sde1 boot
root@ubuntu:/home/ubuntu# mkfs.ext4 /dev/sde2
mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
480496 inodes, 1919744 blocks
95987 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1967128576
59 block groups
32768 blocks per group, 32768 fragments per group
8144 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
root@ubuntu:/home/ubuntu# mkdir root
root@ubuntu:/home/ubuntu# mount /dev/sde2 root
root@ubuntu:/home/ubuntu# wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
--2015-02-14 11:09:24-- http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
Resolving archlinuxarm.org (archlinuxarm.org)... 50.116.36.110
Connecting to archlinuxarm.org (archlinuxarm.org)|50.116.36.110|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz [following]
--2015-02-14 11:09:24-- http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
Resolving os.archlinuxarm.org (os.archlinuxarm.org)... 129.241.205.167, 213.202.193.253, 144.76.72.180, ...
Connecting to os.archlinuxarm.org (os.archlinuxarm.org)|129.241.205.167|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 234858784 (224M) [application/octet-stream]
Saving to: ‘ArchLinuxARM-rpi-2-latest.tar.gz’
100%[======================================>] 234,858,784 3.93MB/s in 59s
2015-02-14 11:10:24 (3.78 MB/s) - ‘ArchLinuxARM-rpi-2-latest.tar.gz’ saved [234858784/234858784]
root@ubuntu:/home/ubuntu# bsdtar -xpf ArchLinuxARM-rpi-2-latest.tar.gz -C root
root@ubuntu:/home/ubuntu# sync
root@ubuntu:/home/ubuntu# mv root/boot/* boot
root@ubuntu:/home/ubuntu# umount boot root
root@ubuntu:/home/ubuntu# df -h
Filesystem Size Used Avail Use% Mounted on
/cow 7.8G 413M 7.4G 6% /
udev 7.7G 4.0K 7.7G 1% /dev
tmpfs 1.6G 1.5M 1.6G 1% /run
/dev/sdc1 15G 985M 14G 7% /cdrom
/dev/loop0 939M 939M 0 100% /rofs
none 4.0K 0 4.0K 0% /sys/fs/cgroup
tmpfs 7.8G 12K 7.8G 1% /tmp
none 5.0M 0 5.0M 0% /run/lock
none 7.8G 80K 7.8G 1% /run/shm
none 100M 60K 100M 1% /run/user
/dev/sdb1 932G 812G 121G 88% /media/ubuntu/Elements')