Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Bob_Zimmerman
Authority
Authority

Mounting snapshots

I recently had the need to get a file from a snapshot on a device which had very little local storage. Rather than using the process from White Paper - Extracting a file from a GAIA Snapshot, I decided to mount the snapshot directly and get the file from there. Thought others here might be interested in the process.

First, you need to find the snapshot's node in the /dev virtual filesystem. Use 'lvdisplay'. Each logical volume will have an entry like this:

 

[Expert@DallasSA]# lvdisplay 
...
  --- Logical volume ---
  LV Path                /dev/vg_splat/lv_DemoSnap
  LV Name                lv_DemoSnap
  VG Name                vg_splat
  LV UUID                7TbELE-hYY0-9fLi-1F3y-K3MN-0AlH-octYt7
  LV Write Access        read/write
  LV Creation host, time DallasSA, 2022-04-12 16:16:55 +0000
  LV Status              available
  # open                 0
  LV Size                14.44 GiB
  Current LE             462
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:4
...

 

Create a directory, and mount the snapshot:

 

[Expert@DallasSA]# mkdir /mnt/snapshot

[Expert@DallasSA]# ls -lh /mnt/snapshot
total 0

[Expert@DallasSA]# mount -o ro /dev/vg_splat/lv_DemoSnap /mnt/snapshot

[Expert@DallasSA]# mount
/dev/mapper/vg_splat-lv_current on / type xfs (rw,inode32)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
/dev/mapper/vg_splat-lv_log on /var/log type xfs (rw,inode32)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
cgroup on /sys/fs/cgroup type tmpfs (rw,uid=0,gid=0,mode=0755)
/dev/mapper/vg_splat-lv_DemoSnap on /mnt/snapshot type xfs (ro)

[Expert@DallasSA]# ls -lh /mnt/snapshot/
total 48M
-rw-rw----  1 admin root    0 Nov 20 15:33 1
-rw-r--r--  1 admin root    0 Dec 29 16:07 DEBUG
drwxr-xr-x  2 admin root   85 Nov 20 15:17 DOCS
-rw-r--r--  1 admin root  542 Oct 17  2020 License.txt
lrwxrwxrwx  1 admin root    7 Apr 12 16:17 bin -> usr/bin
...

 

The '-o ro' argument in the mount command makes it read-only so you don't accidentally change something in the snapshot. With that, you now have read-only access to the whole system as it was when the snapshot was taken.

Edit: Added some newlines between the output of one command and the next command to make the output easier to follow visually.

1 Reply
PhoneBoy
Admin
Admin

That's a groovy tip, thanks for sharing!

0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events