LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-04-2013, 06:45 AM   #1
vmsda
LQ Newbie
 
Registered: Nov 2007
Posts: 24

Rep: Reputation: 0
DD does not recognize partition boundaries?


In playing with Raspberry Pi, I have had to deal with SD Card backups.

In order to have one backup .img to service cards of different sizes, I devised the following "strategy":
1. Shutdown the RPi and remove the card (say, 16GB), attaching it to the PC.
2. Using GParted, resize the partitions to the size of my smallest card (4GB).
3. DD the contents of the card on to an .img backup in my PC.
4. DD the backup .img on to the 4GB card, stick it into the RPi and boot.
5. Using GParted again, resize the bigger card to its original size.

I soon found that step 4 fails because DD does not care about partitions, it images the whole card in step 3, even though it is 80% 'empty'. Since working with SD cards is so excruciatingly slow (DD takes ages), I would like to know whether there is a way around step 3.

In other words, I need a better strategy.
 
Old 04-04-2013, 07:01 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
let we say the disk is /dev/sda
using dd if=/dev/sda will copy the whole disk, dd if=/dev/sda1 will copy the first partition, dd if=/dev/sda2 will copy the second...
 
Old 04-04-2013, 09:09 AM   #3
vmsda
LQ Newbie
 
Registered: Nov 2007
Posts: 24

Original Poster
Rep: Reputation: 0
Wink

Quote:
Originally Posted by pan64 View Post
let we say the disk is /dev/sda
using dd if=/dev/sda will copy the whole disk, dd if=/dev/sda1 will copy the first partition, dd if=/dev/sda2 will copy the second...
Hmmm ... so I would end up with two img files instead of one; ok by me if Raspberry Pi not fussy either. Gonna give it a try.

Thank u so mucho for dze tip.
 
Old 04-04-2013, 10:02 AM   #4
vmsda
LQ Newbie
 
Registered: Nov 2007
Posts: 24

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pan64 View Post
let we say the disk is /dev/sda
using dd if=/dev/sda will copy the whole disk, dd if=/dev/sda1 will copy the first partition, dd if=/dev/sda2 will copy the second...
I ran into problems which I am too inexperienced to tackle. In copying partition by partition as you suggested - from the shrunk bigger SD to to the smaller, the second DD did not end properly because
Code:
  sdb: sdb1 sdb2
[28700.920324] sdb: p2 size 7516160 extends beyond EOD, enabling native capacity
[28700.923037] sd 14:0:0:0: [sdb] No Caching mode page present
[28700.923048] sd 14:0:0:0: [sdb] Assuming drive cache: write through
[28700.924081]  sdb: sdb1 sdb2
[28700.924181] sdb: p2 size 7516160 extends beyond EOD, truncated
[28700.926940] sd 14:0:0:0: [sdb] No Caching mode page present
[28700.926952] sd 14:0:0:0: [sdb] Assuming drive cache: write through
[28700.926961] sd 14:0:0:0: [sdb] Attached SCSI removable disk
[28701.202329] EXT4-fs (sdb2): bad geometry: block count 939519 exceeds size of device (937984 blocks)
Then I decided to investigate why this was so, since I had been careful when resizing the bigger card second partition with GParted.
Code:
Disk /dev/sdb: 3904 MB, 3904897024 bytes
121 heads, 62 sectors/track, 1016 cylinders, total 7626752 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: 0x00014d34

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            8192      122879       57344    c  W95 FAT32 (LBA)
/dev/sdb2          122880     7639039     3758080   83  Linux
vasco@vasco-90X3A:/media$ sudo fdisk -l /dev/sdc

Disk /dev/sdc: 31.9 GB, 31914983424 bytes
64 heads, 32 sectors/track, 30436 cylinders, total 62333952 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: 0x00014d34

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            8192      122879       57344    c  W95 FAT32 (LBA)
/dev/sdc2          122880     7639039     3758080   83  Linux
So it looks that the sizes are ok, although the characteristics are different: sdc is a 32GB class 10 micro SD, whereas sdb is a 4GB class 4 SDHC.

Maybe this threatens getting too complex for what it's worth. Anyway, thanks for forthcoming hints.
 
Old 04-04-2013, 11:41 AM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 2,957

Rep: Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267
Quote:
Originally Posted by vmsda View Post
Code:
Disk /dev/sdb: 3904 MB, 3904897024 bytes
121 heads, 62 sectors/track, 1016 cylinders, total 7626752 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: 0x00014d34

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            8192      122879       57344    c  W95 FAT32 (LBA)
/dev/sdb2          122880     7639039     3758080   83  Linux
The device has a total of 7626572 sectors. Your partition table has partition 2 extending beyond the end of the device (to sector 7639039). I suspect your resizing of the larger drive was inexact due to gparted working in Gigabyte units.
 
Old 04-05-2013, 06:52 AM   #6
vmsda
LQ Newbie
 
Registered: Nov 2007
Posts: 24

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by rknichols View Post
... I suspect your resizing of the larger drive was inexact due to gparted working in Gigabyte units.
How do you suggest I go about sizing it properly, and what tool to use? Thank you for help.
 
Old 04-05-2013, 10:39 AM   #7
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 2,957

Rep: Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267
As gparted works in Megabyte units (not Gigabyte, as I previously indicated), it looks like you could just resize down from your current 3670 MB to 3664 MB and it should fit just right. You will need to adjust the partitioning on the new drive to correct that oversized second partition.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
new partition is not recognize giraf Linux From Scratch 2 05-29-2010 03:18 PM
Slackware will not recognize my second Ntfs partition sectorGr Slackware 16 12-05-2008 08:36 AM
Preserving Hard Disk Partition Boundaries Woodsman Linux - Hardware 1 10-03-2008 04:12 PM
Partition Table (Cylinder boundaries) and lost space imitheos Linux - General 3 09-17-2005 03:59 PM
Are there proper partition block boundaries? GrumpyGnome Linux - Software 0 06-01-2004 04:34 PM


All times are GMT -5. The time now is 01:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration