Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Thank you very much. In that case I have a 10TB disk. Can I use this to take the recover the files than write to the sda? Is it possible? How can I do this?
Code:
[root@bioworkstation /]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 14.6T 0 disk
├─sda1 8:1 0 500M 0 part
└─sda2 8:2 0 14.6T 0 part
sdb 8:16 0 111.8G 0 disk
├─sdb1 8:17 0 500M 0 part /boot
└─sdb2 8:18 0 111.3G 0 part
├─centos-root 253:0 0 50G 0 lvm /
├─centos-swap 253:1 0 4G 0 lvm [SWAP]
└─centos-home 253:2 0 57.2G 0 lvm /home
sdc 8:32 0 10.9T 0 disk
├─sdc1 8:33 0 500M 0 part /run/media/zillur/3d20300c-4bda-4c44-8543-3a6a93451377
└─sdc2 8:34 0 10.9T 0 part
sr0 11:0 1 1024M 0 rom
Thank you very much. I can mount sdc1 anywhere I want. But in sdc1 I have only few MB (494MB) and in sdc2 I have 10 TB. I can't mount sdc2. In that case only mounting sdc1 will solve the problem?
Code:
[root@bioworkstation /]# mount /dev/sdc2 /mordor/
mount: unknown filesystem type 'LVM2_member'
Now the reason you cannot use sda to save files is that you don't know WHERE the files are, thus nothing will know where it can write that will not damage the data on sda.
The only thing you can do is recover a few files and write them on a mounted filesystem - then copy them to a backup storage; delete the files... and then recover some more.
It is a SLOW process - but it is also the ONLY one that is reasonably assured to work reliably.
There are some UNRELIABLE methods and if they don't work the data on the disk is damaged even more. for instance, if sda did NOT have a LVM format, then it MIGHT be possible to recover a filesystem using fsck.
NOTE: THIS IS NOT RELIABLE. And if it doesn't work the data on disk can be damaged even more (see the manpage on fsck.ext4). I DO NOT RECOMMEND THIS as it is really reserved for use by people used to doing such activity. (Fortunately? it doesn't happen that often so people tend to forget that it is even remotely possible). Doing so requires a lot of prior information about the disk - how it was used, formatted, what happened to the disk, how to read the errors.
Another little used method is via debugfs (for ext2/3/4 filesystems), which can be used to examine the disk... and update things. Sometimes even to fix things. I DEFINITELY DO NOT RECOMMEND THIS. It requires knowledge of how the ext filesystems work - and that is NOT generally known. It also requires all the other prior knowledge about the filesystem.
[root@bioworkstation recup_dir.1]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID 5onkyt-tsZg-PhaL-Omal-6so1-SUhZ-reVIQD
LV Write Access read/write
LV Creation host, time localhost, 2016-08-07 17:12:16 -0400
LV Status available
# open 4
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/centos/home
LV Name home
VG Name centos
LV UUID s5n2yy-tehD-XFMb-yDBD-hPNk-LIzc-JiX31P
LV Write Access read/write
LV Creation host, time localhost, 2016-08-07 17:12:16 -0400
LV Status available
# open 3
LV Size 57.24 GiB
Current LE 14653
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID gVxeQQ-GMt4-P2b2-t3Kt-N5JQ-DONY-ej3S3i
LV Write Access read/write
LV Creation host, time localhost, 2016-08-07 17:12:39 -0400
LV Status available
# open 3
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID EMTcko-rQjY-y1gM-cXLj-9HoI-FKuV-zRAvmf
LV Write Access read/write
LV Creation host, time localhost, 2016-08-03 19:50:35 -0400
LV Status NOT available
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead sectors auto
--- Logical volume ---
LV Path /dev/centos/home
LV Name home
VG Name centos
LV UUID heg9yd-s0DY-DzV7-hsh5-601z-nH8B-DAkluO
LV Write Access read/write
LV Creation host, time localhost, 2016-08-03 19:50:35 -0400
LV Status NOT available
LV Size 10.86 TiB
Current LE 2847618
Segments 1
Allocation inherit
Read ahead sectors auto
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID vafBhA-bRUy-0Veu-5yZx-z0qr-2d3l-nYqt8o
LV Write Access read/write
LV Creation host, time localhost, 2016-08-03 19:51:25 -0400
LV Status NOT available
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
Code:
[root@bioworkstation zillur]# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 111.30 GiB
PE Size 4.00 MiB
Total PE 28492
Alloc PE / Size 28477 / 111.24 GiB
Free PE / Size 15 / 60.00 MiB
VG UUID ybqHGe-BUO3-NmWv-DMAw-gqDM-mX1j-vG6vrK
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 10.92 TiB
PE Size 4.00 MiB
Total PE 2861457
Alloc PE / Size 2861442 / 10.92 TiB
Free PE / Size 15 / 60.00 MiB
VG UUID Uroagx-QmOS-wM9V-BlZ4-8iMf-M2hg-BEpgtz
Code:
[root@bioworkstation zillur]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 14.6T 0 disk
├─sda1 8:1 0 500M 0 part
└─sda2 8:2 0 14.6T 0 part
sdb 8:16 0 111.8G 0 disk
├─sdb1 8:17 0 500M 0 part /boot
└─sdb2 8:18 0 111.3G 0 part
├─centos-root 253:0 0 50G 0 lvm /
├─centos-swap 253:1 0 4G 0 lvm [SWAP]
└─centos-home 253:2 0 57.2G 0 lvm /home
sdc 8:32 0 10.9T 0 disk
├─sdc1 8:33 0 500M 0 part /mordor
└─sdc2 8:34 0 10.9T 0 part
sr0 11:0 1 1024M 0 rom
It appears that you have two separate volume groups that are both named "centos". That is a recipie for disaster. You will need to rename the volume group on that "new" disk to something else.
Not that I know. Filenames are stored in the file system metadata which was deleted. Photorec searches the disk and find files based on their signatures. I did say it was going to be difficult.
Let's try this. Assuming (Yes I know -- ass, u, me!) that the PV on sda3 contained exactly one LV, which, in turn, held your filesystem, you can try creating a read-only loop device at the offset where that filesystem would have started, and then see if you can mount that loop device:
Code:
losetup --offset 1048576 -f --show /dev/sda3
### (Ignore the warning about a file smaller than 512 bytes.)
file -s /dev/loop0 /mnt/tmp
fsck -n /dev/loop0
mount -r /dev/loop0 /mnt/tmp
The device name reported by that first command might not be "/dev/loop0". Adjust the name in the subsequent commands as required. If something looks wrong at any stage ("file" doesn't report a filesystem, "fsck" shows something horribly wrong, etc.), don't continue. The "fsck -n" is just a sanity check before attempting to mount. The "-n" will keep it from trying to "fix" anything, since that could well be disasterous for your data. If you don't already have a "/mnt/tmp" mount point directory, you will have to create it first. If you're lucky, all your data will be there.
The easier way to access the PV would be to run "pvextend --restoremissing centos /dev/sda3", but something doesn't seem quite right here, so I don't trust that command to preserve the existing content.
[root@bioworkstation /]# file -s /dev/loop0 /mnt
/dev/loop0: data
/mnt: directory
[root@bioworkstation /]# fsck -n /dev/loop0
fsck from util-linux 2.23.2
e2fsck 1.42.9 (28-Dec-2013)
ext2fs_open2: Bad magic number in super-block
fsck.ext2: Superblock invalid, trying backup blocks...
fsck.ext2: Bad magic number in super-block while trying to open /dev/loop0
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.