Sponsored Content
Top Forums UNIX for Advanced & Expert Users Shrink my partition to new disk Post 302461296 by Corona688 on Sunday 10th of October 2010 01:30:45 AM
Old 10-10-2010
Quote:
Originally Posted by amol28kulkarni
Thanks for the reply
Would it be efficient to copy entire data, is there any way to just copy over the blocks and adjust them according to the newly created filesystem ?
If I knew of any I'd have told you so the first time you asked.
Quote:
Would tar be able to handle the corrupted data like dd can handle since dd does a blind copy.
You can't safely shrink a disk that might be failing -- disk metadata might be corrupted, not just files, making any rearrangement very hazardous to data integrity. You might get a useless hash, or nothing at all. Either make a blind copy, or don't.

There are ways to shrink a blind copy -- compression, or a sparse file -- but none of them leave the resulting image bootable. There's no such thing as a sparse partition, after all, just sparse files. If you're content with having your backup not be bootable, this would work, I wrote sparsecat to help do this. It creates sparse files with a brute-force approach, making sections full of NULLs sparse, meaning it won't screw up because of a trashed sector but might not make everything that COULD be sparse actually sparse. (I don't guarantee its safety or applicability or portability however, it's just a hack I wrote for my own use.)
Code:
dd if=/dev/disk conv=noerror,sync | sparsecat > /mnt/backupdir/sparse.img

Quote:
Is there a way of like creating another sparse image file of 2TB ... then copying over only required data blocks there which will exclude the empty blocks and then resizing the sparse image to 200GB.
If the disk is failing, you can't reliably know which blocks are occupied.

Last edited by Corona688; 10-10-2010 at 02:38 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Disk Partition

Hi All, While my LINUX SERVER installed we didnt' used all the space for partitions. with what tool I can create a new partition or mount point to use the free space. I tried the command fdisk and diskdruid. They are not working. Thanks in advance With Best regards, Varma. (2 Replies)
Discussion started by: jarkvarma
2 Replies

2. Solaris

New disk - how to partition?

Have a solaris x86 running solaris 9. Root disk - logical - mirrored. I added 2 more disks today - and I have mirrored them using array configuration utility. I did a reconfiguration boot - and now I can see the logical disk using format: I then partitioned this the way I wanted (I hope)... (4 Replies)
Discussion started by: frustrated1
4 Replies

3. Solaris

Disk Partition

I have 3 disks to partition in following file system. c1t1d0 = 72gb /prod1 /prod2 /prod3 /prod4 /prod5 I am first time using "format" command to do this. How can i name with specified size. -Adeel (1 Reply)
Discussion started by: deal732
1 Replies

4. UNIX for Advanced & Expert Users

partition disk issue

hi guys, I've got a strange issue, may be one of you has experienced this. SunOS 5.10 Generic_118833-33 sun4u sparc SUNW,Sun-Fire-V440 everything is mirrored. My issue is that I have a umpty directory but seems to have data on. Let me show you # df -h /data Filesystem size used... (10 Replies)
Discussion started by: moustik
10 Replies

5. Filesystems, Disks and Memory

Partition disk

Hi, Can I partition disk in use or would I damage the file store on it? Regards Mehrdad (1 Reply)
Discussion started by: mehrdad68
1 Replies

6. Red Hat

Disk Partition : Skip 1 MB

I want to skip the first cylinder (first 1 MB infact) while I partition my disk using fdisk as it is required that the disk partition to be used (for Oracle RAC Installation) must skip the first 1Mb to avoid overwriting the disk VTOC. The way I am using is: Command (m for help): n Command... (2 Replies)
Discussion started by: jpsingh
2 Replies

7. Solaris

Disk partition slice0

Hi Guys, when performing a disk partition, can any file system other than root be giving to slice 0 or must slice0 hold only root? I am confused about this. Any clarification will be greatly appreciated. Thanks Guys (4 Replies)
Discussion started by: cjashu
4 Replies

8. Red Hat

How to partition your disk?

Hello, I am a new member of the forum. I need an idea on how to partition the disk. My situation is as follows: I have two 3TB disks ognuno.In 6TB total then, but I have to do to force a RAID 1 so my space will be 3TB. I'll have to force install RedHat 5.8 and liquids is to be taken in... (4 Replies)
Discussion started by: Joaquin
4 Replies

9. Red Hat

Shrink LVM partition & create new Linux Primary partition

Hello All, I have a Red Hat Linux 5.9 Server installed with one hard disk & 2 Partitions created on it as follows, /boot - Linux Partition & another is LVM - One VG & under that 5-6 Logical volumes(var,opt,home etc). Here my requirement is to take out 1GB of space from LVM ( Any logical... (5 Replies)
Discussion started by: gr8_usk
5 Replies

10. UNIX for Beginners Questions & Answers

Safe way to shrink lvm vg_*-lv_swap partition and reclaim freed space on Linux?

Hello, # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 1024M 0 rom sda 8:0 0 38.2G 0 disk ├─sda1 8:1 0 500M 0 part /boot └─sda2 8:2 ... (2 Replies)
Discussion started by: centosadmin
2 Replies
E2IMAGE(8)						      System Manager's Manual							E2IMAGE(8)

NAME
e2image - Save critical ext2/ext3/ext4 filesystem metadata to a file SYNOPSIS
e2image [ -r|Q ] [ -f ] device image-file e2image -I device image-file e2image -ra [ -cfnp ] [ -o src_offset ] [ -O dest_offset ] src_fs [ dest_fs ] DESCRIPTION
The e2image program will save critical ext2, ext3, or ext4 filesystem metadata located on device to a file specified by image-file. The image file may be examined by dumpe2fs and debugfs, by using the -i option to those programs. This can assist an expert in recovering cat- astrophically corrupted filesystems. In the future, e2fsck will be enhanced to be able to use the image file to help recover a badly dam- aged filesystem. When saving an e2image for debugging purposes, using either the -r or -Q options, the filesystem must be unmounted or be mounted read/only, in order for the image file to be in a consistent state. This requirement can be overridden using the -f option, but the resulting image file is very likely not going to be useful. If image-file is -, then the output of e2image will be sent to standard output, so that the output can be piped to another program, such as gzip(1). (Note that this is currently only supported when creating a raw image file using the -r option, since the process of creating a normal image file, or QCOW2 image currently requires random access to the file, which cannot be done using a pipe. This restriction will hopefully be lifted in a future version of e2image.) It is a very good idea to create image files for all of filesystems on a system and save the partition layout (which can be generated using the fdisk -l command) at regular intervals --- at boot time, and/or every week or so. The image file should be stored on some filesystem other than the filesystem whose data it contains, to ensure that this data is accessible in the case where the filesystem has been badly damaged. To save disk space, e2image creates the image file as a sparse file, or in QCOW2 format. Hence, if the sparse image file needs to be copied to another location, it should either be compressed first or copied using the --sparse=always option to the GNU version of cp. This does not apply to the QCOW2 image, which is not sparse. The size of an ext2 image file depends primarily on the size of the filesystems and how many inodes are in use. For a typical 10 gigabyte filesystem, with 200,000 inodes in use out of 1.2 million inodes, the image file will be approximately 35 megabytes; a 4 gigabyte filesys- tem with 15,000 inodes in use out of 550,000 inodes will result in a 3 megabyte image file. Image files tend to be quite compressible; an image file taking up 32 megabytes of space on disk will generally compress down to 3 or 4 megabytes. RESTORING FILESYSTEM METADATA USING AN IMAGE FILE
The -I option will cause e2image to install the metadata stored in the image file back to the device. It can be used to restore the filesystem metadata back to the device in emergency situations. WARNING!!!! The -I option should only be used as a desperation measure when other alternatives have failed. If the filesystem has changed since the image file was created, data will be lost. In general, you should make a full image backup of the filesystem first, in case you wish to try other recovery strategies afterwards. RAW IMAGE FILES
The -r option will create a raw image file instead of a normal image file. A raw image file differs from a normal image file in two ways. First, the filesystem metadata is placed in the proper position so that e2fsck, dumpe2fs, debugfs, etc. can be run directly on the raw image file. In order to minimize the amount of disk space consumed by a raw image file, the file is created as a sparse file. (Beware of copying or compressing/decompressing this file with utilities that don't understand how to create sparse files; the file will become as large as the filesystem itself!) Secondly, the raw image file also includes indirect blocks and directory blocks, which the standard image file does not have, although this may change in the future. Raw image files are sometimes used when sending filesystems to the maintainer as part of bug reports to e2fsprogs. When used in this capacity, the recommended command is as follows (replace hda1 with the appropriate device): e2image -r /dev/hda1 - | bzip2 > hda1.e2i.bz2 This will only send the metadata information, without any data blocks. However, the filenames in the directory blocks can still reveal information about the contents of the filesystem that the bug reporter may wish to keep confidential. To address this concern, the -s option can be specified. This will cause e2image to scramble directory entries and zero out any unused portions of the directory blocks before writing the image file. However, the -s option will prevent analysis of problems related to hash-tree indexed directories. Note that this will work even if you substitute "/dev/hda1" for another raw disk image, or QCOW2 image previously created by e2image. QCOW2 IMAGE FILES The -Q option will create a QCOW2 image file instead of a normal, or raw image file. A QCOW2 image contains all the information the raw image does, however unlike the raw image it is not sparse. The QCOW2 image minimize the amount of disk space by storing data in special format with pack data closely together, hence avoiding holes while still minimizing size. In order to send filesystem to the maintainer as a part of bug report to e2fsprogs, use following commands (replace hda1 with the appropri- ate device): e2image -Q /dev/hda1 hda1.qcow2 bzip2 -z hda1.qcow2 This will only send the metadata information, without any data blocks. However, the filenames in the directory blocks can still reveal information about the contents of the filesystem that the bug reporter may wish to keep confidential. To address this concern, the -s option can be specified. This will cause e2image to scramble directory entries and zero out any unused portions of the directory blocks before writing the image file. However, the -s option will prevent analysis of problems related to hash-tree indexed directories. Note that QCOW2 image created by e2image is regular QCOW2 image and can be processed by tools aware of QCOW2 format such as for example qemu-img. You can convert a qcow2 image into a raw image with: e2image -r hda1.qcow2 hda1.raw This can be useful to write a qcow2 image containing all data to a sparse image file where it can be loop mounted, or to a disk partition. Note that this may not work with qcow2 images not generated by e2image. INCLUDING DATA
Normally e2image only includes fs metadata, not regular file data. The -a option can be specified to include all data. This will give an image that is suitable to use to clone the entire FS or for backup purposes. Note that this option only works with the raw or QCOW2 for- mats. The -p switch may be given to show progress. If the file system is being cloned to a flash-based storage device (where reads are very fast and where it is desirable to avoid unnecessary writes to reduce write wear on the device), the -c option which cause e2image to try reading a block from the destination to see if it is identical to the block which e2image is about to copy. If the block is already the same, the write can be skipped. The -n option will cause all of the writes to be no-ops, and print the blocks that would have been written. OFFSETS
Normally a filesystem starts at the beginning of a partition, and e2image is run on the partition. When working with image files, you don't have the option of using the partition device, so you can specify the offset where the filesystem starts directly with the -o option. Similarly the -O option specifies the offset that should be seeked to in the destination before writing the filesystem. For example, if you have a dd image of a whole hard drive that contains an ext2 fs in a partition starting at 1 MiB, you can clone that fs with: e2image -aro 1048576 img /dev/sda1 Or you can clone a fs into an image file, leaving room in the first MiB for a partition table with: e2image -arO 1048576 /dev/sda1 img If you specify at least one offset, and only one file, an in-place move will be performed, allowing you to safely move the filesystem from one offset to another. AUTHOR
e2image was written by Theodore Ts'o (tytso@mit.edu). AVAILABILITY
e2image is part of the e2fsprogs package and is available from http://e2fsprogs.sourceforge.net. SEE ALSO
dumpe2fs(8), debugfs(8) E2fsprogs version 1.44.1 March 2018 E2IMAGE(8)
All times are GMT -4. The time now is 04:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy