LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 02-24-2013, 08:14 AM   #1
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Rep: Reputation: 70
Question Which command performs this operation?


Hi gang,

I've been away from Linux for 18 months and have forgotten a couple of things (my advanced age, no doubt, doesn't help). What is the bash command which lists all volumes physically attached to the system whether mounted or not?

Thanks, CC.
 
Old 02-24-2013, 08:19 AM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Try following:
Code:
~$ dmesg
~$ df -h
~$ fdisk -l
~$ cat /etc/fstab
~$ cat /etc/mtab
Check manuals of commands also:
Code:
~$ man <command_name>
 
Old 02-24-2013, 08:26 AM   #3
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Hi all,

For the purposes of imaging a 4Gb SD card containing a Raspberry Pi operating system to an 8Gb usb stick in such a way as to be able to reload the O/S in its original, bootable format to the card from the stick if needed, would the following command do the job?

Code:
# dd if=/dev/sda of=/dev/sdb bs=4096 conv=noerror notrunc
And should both card and stick be unmounted when running this operation?

I'm a bit rusty so thought I'd best check first...

Last edited by Completely Clueless; 02-24-2013 at 09:03 AM.
 
Old 02-24-2013, 08:43 AM   #4
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Yes, it will.
Code:
dd if=/path/to/sd_card of=/path/to/usb_stick bs=4096 conv=noerror notrunc
But once let's know that does SD card contain a 'single bootable disk image of the OS' or extracted content of the OS or anything else?
 
Old 02-24-2013, 08:56 AM   #5
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Quote:
Originally Posted by shivaa View Post

But once let's know that does SD card contain a 'single bootable disk image of the OS' or extracted content of the OS or anything else?
Not quite sure what you mean. The SD card I wish to image contains an installation of Raspbian Linux which the Raspberry Pi boots from. That's all.
 
Old 02-24-2013, 09:14 AM   #6
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Quote:
Not quite sure what you mean. The SD card I wish to image contains an installation of Raspbian Linux which the Raspberry Pi boots from. That's all.
I simply mean, what's content of SD card? Does it contain a single file (with .iso as file extension) or lots of files?
 
Old 02-24-2013, 09:43 AM   #7
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by Completely Clueless View Post
What is the bash command which lists all volumes physically attached to the system whether mounted or not?
That would be "fdisk -l"
 
Old 02-24-2013, 09:52 AM   #8
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
To get more info about volumes with recognizable content, you can use blkid. For example:
Code:
# blkid
/dev/sda2: LABEL="F12root" UUID="51160411-a0bb-40e8-bac0-bedd7ff57c09" TYPE="ext3" 
/dev/sda5: LABEL="F12usr" UUID="68cfc1a8-5298-48d1-bc6e-fa412f79e082" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sda6: LABEL="F12var" UUID="43a87d4c-5aea-4eb2-b595-77593f99e788" TYPE="ext3" 
/dev/sda8: LABEL=":/srv" UUID="e1ddf9ba-01b5-404b-a2f1-401744fc3587" TYPE="ext3" 
/dev/sda10: UUID="F3fL1l-vHhM-qdT9-2QK4-oeZU-AN3m-1owI18" TYPE="LVM2_member" 
/dev/sda11: UUID="nQdat7-9xF4-Jp11-9kTu-pJIp-10AQ-YBPbMU" TYPE="LVM2_member" 
/dev/mapper/swap01: UUID="bee77b2d-6bd3-4831-b464-e5a6548c2628" TYPE="swap" 
/dev/sdb1: UUID="5866c8fa-3daf-4840-8ddc-02a8d7b5cd33" TYPE="crypto_LUKS" 
/dev/sdb2: UUID="e37ae7b0-085f-4e91-b74a-575d265f60b9" TYPE="crypto_LUKS" 
#
 
1 members found this post helpful.
Old 02-24-2013, 10:10 AM   #9
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Quote:
Originally Posted by shivaa View Post
I simply mean, what's content of SD card? Does it contain a single file (with .iso as file extension) or lots of files?
The fact that it's a card with a Raspbian system on it that runs on a Pi would indicate that it's NOT a single file .iso image, would it not? This is why I don't really understand your question...
 
Old 02-24-2013, 10:11 AM   #10
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Quote:
Originally Posted by rknichols View Post
To get more info about volumes with recognizable content, you can use blkid. For example:
Code:
# blkid
/dev/sda2: LABEL="F12root" UUID="51160411-a0bb-40e8-bac0-bedd7ff57c09" TYPE="ext3" 
/dev/sda5: LABEL="F12usr" UUID="68cfc1a8-5298-48d1-bc6e-fa412f79e082" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sda6: LABEL="F12var" UUID="43a87d4c-5aea-4eb2-b595-77593f99e788" TYPE="ext3" 
/dev/sda8: LABEL=":/srv" UUID="e1ddf9ba-01b5-404b-a2f1-401744fc3587" TYPE="ext3" 
/dev/sda10: UUID="F3fL1l-vHhM-qdT9-2QK4-oeZU-AN3m-1owI18" TYPE="LVM2_member" 
/dev/sda11: UUID="nQdat7-9xF4-Jp11-9kTu-pJIp-10AQ-YBPbMU" TYPE="LVM2_member" 
/dev/mapper/swap01: UUID="bee77b2d-6bd3-4831-b464-e5a6548c2628" TYPE="swap" 
/dev/sdb1: UUID="5866c8fa-3daf-4840-8ddc-02a8d7b5cd33" TYPE="crypto_LUKS" 
/dev/sdb2: UUID="e37ae7b0-085f-4e91-b74a-575d265f60b9" TYPE="crypto_LUKS" 
#
Ooh. That's nifty. Not seen that command before.
The one I had in mind was fdisk -l which the guys above correctly identified.
 
Old 02-24-2013, 05:19 PM   #11
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Oops! Just noticed I made a typo. Should be:
Code:
# dd if=/dev/sda of=/dev/sdb bs=4096 conv=noerror,notrunc
Some authorities say that the source drive should never be mounted for this operation; others say neither source nor target should be. Anyone super-knowledgeable care to settle the question?
 
Old 02-24-2013, 09:00 PM   #12
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by Completely Clueless View Post
Oops! Just noticed I made a typo. Should be:
Code:
# dd if=/dev/sda of=/dev/sdb bs=4096 conv=noerror,notrunc
Some authorities say that the source drive should never be mounted for this operation; others say neither source nor target should be. Anyone super-knowledgeable care to settle the question?
The target definitely shouldn't be mounted, I don't think it makes a difference if the source is mounted or not.
 
Old 02-24-2013, 10:44 PM   #13
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
The source should not be mounted read/write (read-only is OK) or the target will end up with a mildly corrupted filesystem that needs an fsck to clean it up. (Try running "fsck -f -n" on a mounted filesystem if you want to see what to expect. Do not leave off the "-n" or fsck will be very unhappy with you.)
 
Old 02-25-2013, 03:41 PM   #14
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Well in that case it's clear that neither drive should be mounted, then. Next question that arises is: how does the file system get corrupted?? I'm guessing dd isn't the culprit here, so what is?
 
Old 02-25-2013, 06:11 PM   #15
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
While a filesystem is mounted read/write, the on-disk metadata is not in a totally clean state. One fairly obvious case is files that have been deleted but are still held open by some process. These will show up in fsck as orphaned inodes (inode is busy, but is not linked from any directory), and fsck will dutifully recover these and put them in lost+found. For any file that is open for writing, the only true copy of the inode state is in memory, not on the disk, and that is true for block allocation maps and group descriptors as well. At a minimum, the "needs_recovery" flag will always be set in the super block.
 
1 members found this post helpful.
  


Reply



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
Unable to generate GPG key, command get_passphrase failed: Operation cancelled markings Linux - Software 9 03-26-2012 07:40 AM
How to recover data and reverse the operation done by dd command getasif Linux - Laptop and Netbook 6 10-18-2011 06:14 PM
how to find the equivalent command of a gui operation??? lemon09 Linux - General 1 04-12-2010 11:57 AM
quick question on order of operation with command substitution dsollen Linux - Newbie 3 09-15-2009 08:04 AM
older computer performs better new one maenho Linux - Hardware 6 12-18-2004 03:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:59 PM.

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
Open Source Consulting | Domain Registration