LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices



Reply
 
Search this Thread
Old 03-01-2012, 09:53 AM   #1
saman_artorious
Member
 
Registered: Sep 2008
Posts: 78

Rep: Reputation: 1
smbclient & dd


you know I am told to get an image of the whole ubuntu system on my server shared folder.
If you have used dd before to get an image of the occupied space on the system please lemme know bout your command.
(I preferably want dd to only get an image of the occupied file system not the free space)

Well, here comes the next part. You know, though I can view my server shared folder graphically, I cannot do it using shell command. The server has the following path:
Code:
smb://username@safe/mysharedfolder
(username and mysharedfolder have the same name)

I tried different commands for smbclient to connect to the server but it failed. Any helps would be appreciable.
 
Old 03-01-2012, 11:20 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
dd will copy everything, including free space but you can a) set the free space to all zeroes and b) compress the output. Assuming the file system you want to copy is / and it is on /dev/sda1, as root:
Code:
dd if=/dev/zero of=/trash
rm /trash
dd if=/dev/sda1 conv=sync,noerror | gzip > /path/to/file/not/on/root/filesystem/sda.gz
If the contents of the / file system are changing during the above you will not get a "snapshot in time" so it is better run after booting a standalone system such as Knoppix or a functional live CD/DVD, in which case change /trash as appropriate.
 
Old 03-01-2012, 12:04 PM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
It isn't clear whether you want to use the SMB filesystem as the source or as the destination of the dd image. dd works on files and devices, but not on network shares, which are neither. If you want to make a backup of a network share, you are much better off to use either a backup utility (maybe even dd) on the file server host.
If you want to make an image of a partition on a local filesystem, and store the image as a file on a network share, then I suggest mounting the SMB share on your local filesystem before starting to create the dd image, and use the mounted network filesystem as the storage for the dd image.

Making a dd image of a mounted partition is a recipe for BAD THINGS. A file oriented backup using rsync is probably a better idea, and will be more efficient in terms of net data transfer, and size of the resulting copy, although the result will not be a single image file. You can still create a single file version of the backup, if that is what you require for archival or transport purposes.

--- rod.

Last edited by theNbomr; 03-01-2012 at 12:08 PM.
 
Old 03-02-2012, 07:34 AM   #4
saman_artorious
Member
 
Registered: Sep 2008
Posts: 78

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by catkin View Post
dd will copy everything, including free space but you can a) set the free space to all zeroes and b) compress the output. Assuming the file system you want to copy is / and it is on /dev/sda1, as root:
Code:
dd if=/dev/zero of=/trash
rm /trash
dd if=/dev/sda1 conv=sync,noerror | gzip > /path/to/file/not/on/root/filesystem/sda.gz
If the contents of the / file system are changing during the above you will not get a "snapshot in time" so it is better run after booting a standalone system such as Knoppix or a functional live CD/DVD, in which case change /trash as appropriate.
I didn't get the last part! in the code you gather all free space in /trash, and then remove trash. So, there only remains occupied space. I don't understand the next step related to live CD/DVD, what that's gonna do with this at all? could you explain it in more detail plz.

and, let's be more accurate here, I need frist to mount my server shared folder using this
mount -t cifs //safe/mysharedfolder -o username=user,password="password" /mnt/share
and then get a backup of whole system n place it on server. this I shall only change the path to file not on root filesystem to /mnt/shared right?
Code:
dd if=/dev/zero of=/trash
rm /trash
dd if=/dev/sda1 conv=sync,noerror | gzip > /path/to/file/not/on/root/filesystem/sda.gz

Last edited by saman_artorious; 03-02-2012 at 07:39 AM.
 
Old 03-02-2012, 07:40 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
Same as what theNbomr wrote -- using dd to copy a mounted file system is not good so, if it is the / file sytem you want to back up you can't umount it while it is being used to run GNU/Linux. The solution is to boot GNU/Linux from a CD or DVD.
 
Old 03-02-2012, 12:13 PM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Quote:
Originally Posted by saman_artorious View Post
Code:
dd if=/dev/zero of=/trash
rm /trash
dd if=/dev/sda1 conv=sync,noerror | gzip > /path/to/file/not/on/root/filesystem/sda.gz
This is very likely to be the root filesystem. Creating an image of the mounted root filesystem will definitely not be a good idea, if you intend to restore it as a working root filesystem image in the future.
--- rod.
 
Old 03-02-2012, 02:54 PM   #7
saman_artorious
Member
 
Registered: Sep 2008
Posts: 78

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by catkin View Post
Same as what theNbomr wrote -- using dd to copy a mounted file system is not good so, if it is the / file sytem you want to back up you can't umount it while it is being used to run GNU/Linux. The solution is to boot GNU/Linux from a CD or DVD.
should it be a live cd/dvd? or i can also use the same distribution dvd? and if any, shall simply log in in live mode and then take a backup of the / file system? but would the / file system, when i login from a live cd or dvd? bcoz m not mounting my system anymore whereas the / filesystem of the live cd or dvd is mounted instead!
 
Old 03-02-2012, 03:03 PM   #8
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Any CD/DVD that does not mount the partition which you are trying back-up would be suitable. That probably includes most live CDs/DVDs, including most installation CDs. If you can get to a shell, you should be able determine what is mounted by either running mount with no arguments, or inspecting /etc/mtab. Even if the target partition is mounted, you can very likely safely unmount (umount) it for the purpose of making a backup.
--- rod.
 
  


Reply

Tags
server, smbclient, ubuntu 11.04


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
how to use smbclient hen770 Linux - Software 2 10-10-2011 01:17 AM
Smbclient cannot use Mget & Mput s1ddh4rta Linux - Software 4 03-06-2009 08:25 AM
AOL UK && BT Voyager 100 && Slackware 10.2 && RP-PPPoE pitt0071 Linux - Networking 3 01-17-2006 07:10 AM
Japanese canna won't work : Warning: かな漢字変&am OrganicOrange84 Debian 3 06-30-2005 03:28 PM
Phục hồi dữ liệu bị mất???, cứ pollsite General 1 06-27-2005 01:39 PM


All times are GMT -5. The time now is 06:44 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration