Thursday, March 5, 2015

Resize partiton on SD card

How to resize the partition on SDcard?
Scenario: You have written an image onto sdcard and that image is not using all the space on the disk
using gparted and parted.

# parted /dev/mmcblk0
- unit chs
- print
(This will show capacity of the sdcard in terms of cylinder-head-sector)
Max value is capcity -1 cylinder.

-- Sample --
$ sudo parted /dev/sdd
(parted) unit chs
(parted) print
Disk /dev/sdd: 121535,3,31
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 121536,4,32.  Each cylinder is 65.5kB.
Partition Table: msdos

Number  Start      End         Type     File system     Flags
 1      16,0,0     1215,3,31   primary  fat32           lba
 2      1232,0,0   26671,3,31  primary  ext4
 3      26688,0,0  29743,3,31  primary  linux-swap(v1)
-- Sample end --

then use "resizepart" command to resize the partition.

Optionally i can use gparted to do the same thing graphically.

Wednesday, February 18, 2015

Useful Commandline

To copy files preserving parents use --parent
$ cp --parents source destination