DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 14th July 2009
gosha gosha is offline
Spam Deminer
 
Join Date: Jun 2008
Location: China
Posts: 256
Default backup fdisk partitions

Hi again,
I would like to backup my drive with Vista in it, because I want to get rid of it and use my new thinkpad for openbsd only. But I still want to backup what came with it.
Since all my attempts using ThinkVintage failed, I'm thinking of copying the whole disk, or at least the three partitions that came with the laptop.
They are three HPFS/QNX/AUX partitions.
How can I backup everything so that if I wanted to I could copy back all of it into the disk and have it as "new"?
Is dd an option?
What's the best way to do this, and using less space space?
tks
Reply With Quote
  #2   (View Single Post)  
Old 14th July 2009
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,977
Default

Vista uses NTFS. OpenBSD's NTFS driver has been in "experimental" state for years -- it is limited to read/only access, and requires a custom kernel. Even with the driver configured, OpenBSD is not usable for backup/restore of NTFS data. Of course, dd(1) is an option, but it is a sector-by-sector copy of an entire partition, or, of an entire disk.

For NTFS backup, I prefer the ntfsclone utility, from the Linux-NTFS project. It will back up and restore an NTFS partition, copying only the saved data. This requires a different OS, of course. I have seen reference to ports of their toolset to FreeBSD, but I use a liveCD of Puppy Linux to run ntfsclone on Windows workstations, both WXP and Vista.

You would also want to back up the partition table; that can be done from OpenBSD's fdisk(8).
Reply With Quote
  #3   (View Single Post)  
Old 14th July 2009
gosha gosha is offline
Spam Deminer
 
Join Date: Jun 2008
Location: China
Posts: 256
Default

then I could use Puppy Linux from a usb thumb to do the job?
What if I use dd? Is it possible to gzip the resulting file? How much compression would I get?
Reply With Quote
  #4   (View Single Post)  
Old 14th July 2009
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,977
Default

I understand Puppy Linux can be installed on a USB drive. If you can boot from a USB mass storage device, than, yes, you could use it that way.

The output from dd or from ntfsclone can be futher compressed. How much is data dependent, of course.

Examples:

Using dd to back up partition "i" on wd0 to a server on your network, from OpenBSD:

# dd if=/dev/rwd0i bs=10m | gzip | ssh backup@server.gosha.net "cat > sd0i.dd.gz"

Using ntfsclone to back up /dev/hda1 to the same server, from Linux:

# ntfsclone -s -o - /dev/hda1 | gzip | ssh backup@server.gosha.net "cat > hda1.ntfs.gz"
Reply With Quote
  #5   (View Single Post)  
Old 14th July 2009
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Banned
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Default

Using dd(1) could be a viable solution, gzip/bzip2 would likely be capable of compressing the file considerably.. but it would take time.

If you have a 30GB partition, with 5GB used.. the compressed image would likely be smaller then 5GB, because most of it would be 0's.

If you do plan to use dd(1), make sure you use a larger block size.. and raw device nodes.. otherwise it'll be unbelievably slow.

Good luck.
Reply With Quote
  #6   (View Single Post)  
Old 14th July 2009
gosha gosha is offline
Spam Deminer
 
Join Date: Jun 2008
Location: China
Posts: 256
Default

thanks a lot, all very usefull
I think I'll go and try dd first
Reply With Quote
  #7   (View Single Post)  
Old 14th July 2009
gosha gosha is offline
Spam Deminer
 
Join Date: Jun 2008
Location: China
Posts: 256
Default

well... I was trying to dd the whole disk with dd if=/dev/sd0 ...
I booted the bsd install bsd.rd, and was thinking of doing it from there, but it does not have gzip. I think it would be better to gzip before sending, because this machine is faster, and I don't know how long it would take to send 250g even though the computers are in the same room...
Reply With Quote
  #8   (View Single Post)  
Old 14th July 2009
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,977
Default

That should be dd if=/dev/rsd0c ...

bsd.rd is not required.

Boot in single user mode; the root partition will be read/only, and no other partitions will be mounted. Mount what you need (such as /usr) read/only, then run your command.
Reply With Quote
  #9   (View Single Post)  
Old 14th July 2009
gosha gosha is offline
Spam Deminer
 
Join Date: Jun 2008
Location: China
Posts: 256
Default

tks
and then I should mount read-only /usr to get gzip and ssh, right?
Also, if I write count=1 I will save the partition table, right?
Reply With Quote
Old 14th July 2009
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,977
Default

Quote:
Originally Posted by gosha View Post
...I should mount read-only /usr to get gzip and ssh, right?
I'd written, above:
Quote:
Originally Posted by jggimi
...mount what you need (such as /usr) read/only...
I have found ldd(1) extremely helpful for finding out what's needed by any executable. In this case, you need /usr/bin, /usr/lib, and /usr/libexec available:
Code:
$ ldd `which ssh`
/usr/bin/ssh:
    Start     End      Type Open Ref GrpRef Name
    1c000000 3c018000 exe  1    0    0      /usr/bin/ssh
    08269000 2826e000 rlib 0    1    0      /usr/lib/libgssapi.so.5.0
    058b0000 258c0000 rlib 0    1    0      /usr/lib/libkrb5.so.17.0
    0a0e0000 2a120000 rlib 0    1    0      /usr/lib/libcrypto.so.18.0
    0ac9d000 2aca5000 rlib 0    1    0      /usr/lib/libz.so.4.1
    0b684000 2b689000 rlib 0    1    0      /usr/lib/libdes.so.9.0
    0f7bc000 2f7f5000 rlib 0    1    0      /usr/lib/libc.so.51.0
    030ab000 030ab000 rtld 0    1    0      /usr/libexec/ld.so
$ ldd `which gzip`
/usr/bin/gzip:
    Start     End      Type Open Ref GrpRef Name
    1c000000 3c005000 exe  1    0    0      /usr/bin/gzip
    0a49e000 2a4a6000 rlib 0    1    0      /usr/lib/libz.so.4.1
    07c65000 27c9e000 rlib 0    1    0      /usr/lib/libc.so.51.0
    02399000 02399000 rtld 0    1    0      /usr/libexec/ld.so
$
Quote:
Also, if I write count=1 I will save the partition table, right?
It will only save the primary partition table. It will miss any extended partition tables, and it will miss any boot loaders stored in the first track. Personally, I prefer fdisk(8) for saving and restoring MBRs; I don't back up my multibooter -- which is GAG -- I reinstall it.
Reply With Quote
Old 14th July 2009
gosha gosha is offline
Spam Deminer
 
Join Date: Jun 2008
Location: China
Posts: 256
Default

with bs=100m I would get
dd: input buffer: Cannot allocate memory
it works with bs=10, did not try other values
Hopefully it will be finished overnight.
Reply With Quote
Old 14th July 2009
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Banned
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Default

I do hope you meant bs=10m, because bs=10 would be 10 bytes.. smaller then the default of 512.

If you did bs=10 instead of bs=10m, it will take a VERY long time.
Reply With Quote
Old 14th July 2009
gosha gosha is offline
Spam Deminer
 
Join Date: Jun 2008
Location: China
Posts: 256
Default

yes it was 10m, it took 5 hours for a 250g drive with a final .gz file of 43.8g.

jggimi: how do I backup the partition table with fdisk? Is it the -u option? But hasn't dd if=/dev/rsd0c saved the whole of it, including partition table etc? In that case I should not need any more backing up, right?
Reply With Quote
Old 14th July 2009
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Banned
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Default

The partition table is within the MBR, the MBR is the first sector on the disk... a sector is 512 bytes.

You do have a copy of the partiton table if you used rsd0c, but you can always make another that's separate from the compressed image.
$ sudo dd if=/dev/rsd0c of=mbr.bin bs=512 count=1

You can also just save the output from fdisk if you ONLY want the partition table.
# fdisk sd0 > pt.txt

Glad it worked out for you.
Reply With Quote
Old 14th July 2009
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,977
Default

The dd example from BSDfan666, will copy the first sector, which includes the primary MBR. But, as I mentioned above, it will not copy any extended partition tables.

BSDfan666's example of backing up the MBR with fdisk saves the primary and all extended partitions in text format. The restoration is done manually.

To back up primary and any extended MBRs, just back up the first track:

# dd if=/dev/rsd0c of=mbr.backup count=63
Reply With Quote
Old 14th July 2009
gosha gosha is offline
Spam Deminer
 
Join Date: Jun 2008
Location: China
Posts: 256
Default

thanks a lot to both of you, it was all very helpful, and I finally start to understand a bit more about partition tables.
Now I might give FreeBSD a try, although, I'm quite used to OpenBSD and would like to stick to it. But the ram issue and some ports I'd like push me away.
Reply With Quote
Old 15th July 2009
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 1,027
Default

Quote:
Originally Posted by jggimi View Post
To back up primary and any extended MBRs, just back up the first track:

# dd if=/dev/rsd0c of=mbr.backup count=63
I'm confused. Did you mean to say here that backing up the first track saves any boot loaders that may be stored there (which you said up-thread)? My understanding is that the extended boot records are spread out accross the whole disk, each right in front of the logical partition it defines. Thanks for any clarification!
Reply With Quote
Old 16th July 2009
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,977
Default

You are correct, and I wrote misleading information, above. Extended partition tables are located within extended partitions, and would not be located within the first track. There may be one or more of these, chained recursively.

The first track on the drive contains the MBR and may also include programmatic information, such as a multiboot loader.
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
fdisk Question Crotalus FreeBSD Installation and Upgrading 2 10th February 2010 08:10 AM
backup freeBSD 7.0 using Backup Exec ccc FreeBSD General 2 25th April 2009 09:23 PM
fdisk -B does not rewrite the mbr kasse NetBSD General 0 25th November 2008 11:07 PM
fdisk can't see (Vista) ntfs partitions caesius FreeBSD General 7 23rd September 2008 01:01 AM
FreeBSD equivalent of DOS's fdisk /mbr Nobber FreeBSD General 5 3rd June 2008 07:19 AM


All times are GMT. The time now is 06:23 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick