Skip to contentSkip to conversation

LVM + XFS + external log + snapshots

DISCUSSION aurfalien 4 participants 8 messages Jun 22, 2013 – Jun 24, 2013

lore
Share & tools
lore

aurfalien

author
#0 lore raw

Hi all,

So I have an XFS file system within LVM which has an external log.

My mount option in FSTAB is;

/dev/vg_spock_data/lv_data /data xfs logdev=/dev/sdc1,nobarrier,logbufs=8,noatime,nodiratime 1 1

All is well no issues and very fast.

Now I'd like to snapshot this bad boy and then run rsnapshot to create a few days backup.

A snapshot volume is created w/o issue;

lvcreate -L250G -s -n datasnapshot /dev/vg_spock_data/lv_data

But when i try to mount the file system;

mount /dev/vg_spock_data/datasnapshot /snapshot -o nouuid,ro

I get this;

mount: wrong fs type, bad option, bad superblock on /dev/mapper/vg_anette_data-datasnapshot,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so

The command dmesg shows;

XFS (dm-3): filesystem is marked as having an external log; specify logdev on the mount command line. XFS (dm-3): SB validate failed

So I then use this mount option;

mount /dev/vg_anette_data/datasnapshot /snapshot -o logdev=/dev/sdc1,nouuid,ro

But get this error;

mount: /dev/mapper/vg_spock_data-datasnapshot already mounted or /snapshot busy

And the command dmesg shows;

XFS (dm-3): Invalid device [/dev/sdc1], error=-16

Am I doing something wrong or is this not possible?

I prefer being in error, I often am anyways.

Thanks in advance,

- aurf
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw

Sorry for err aurfalien, first reply didn't make the list.

Quoted 3 lines · aurfalien

Hi all,

So I have an XFS file system within LVM which has an external log.

Migrate to internal logs as snaps are easy. Since delaylog (2.6.39+) external logs are generally no longer needed, provide little to no advantage as log bandwidth drops dramatically. If RHEL or CentOS that's 6.2 or later.

...

Quoted 3 lines

lvcreate -L250G -s -n datasnapshot /dev/vg_spock_data/lv_data

But when i try to mount the file system;

For now, to get past this current problem, you must snapshot both the filesystem and the log, during the same freeze. You're currently cloning the Lone Ranger without cloning Tonto. Ain't gonna work. And it looks like the log device doesn't reside on LVM, so you're outta luck, can't snap it.

Quoted 4 lines

logdev=/dev/sdc1

Am I doing something wrong or is this not possible?

Your first error was putting the log on raw storage instead of an LV. If your kernel is new enough to support delaylog, then your 2nd error was using an external log. External logs were once useful for high metadata workloads, but since delaylog they are largely no longer needed.

xfsdump the filesytem, mkfs.xfs with an internal log, then xfsrestore.

Alternatively you could keep the external log: Remount the live XFS using an alternate location for the log. Put an LV on sdc1. Then remount again using this new LV as the log location. Then you can snap both XFS and the log, and mount the snap with the matching log.

Signature · 6 lines
Stan

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
author
#2 lore raw

Many many thanks Stan.

It appears that I poorly architected the file system layout.

Will most likely move the log to another device, then LVM the original device (sdc1) and move it back.

Many many thanks for the info, very top tier expert level for sure.

- aurf

Quoted 33 lines · Stan Hoeppner

Sorry for err aurfalien, first reply didn't make the list.

Quoted 3 lines · aurfalien

Hi all,

So I have an XFS file system within LVM which has an external log.

Migrate to internal logs as snaps are easy. Since delaylog (2.6.39+) external logs are generally no longer needed, provide little to no advantage as log bandwidth drops dramatically. If RHEL or CentOS that's 6.2 or later.

...

Quoted 3 lines

lvcreate -L250G -s -n datasnapshot /dev/vg_spock_data/lv_data

But when i try to mount the file system;

For now, to get past this current problem, you must snapshot both the filesystem and the log, during the same freeze. You're currently cloning the Lone Ranger without cloning Tonto. Ain't gonna work. And it looks like the log device doesn't reside on LVM, so you're outta luck, can't snap it.

Quoted 4 lines

logdev=/dev/sdc1

Am I doing something wrong or is this not possible?

Your first error was putting the log on raw storage instead of an LV. If your kernel is new enough to support delaylog, then your 2nd error was using an external log. External logs were once useful for high metadata workloads, but since delaylog they are largely no longer needed.

Quoted 14 lines

xfsdump the filesytem, mkfs.xfs with an internal log, then xfsrestore.

Alternatively you could keep the external log: Remount the live XFS using an alternate location for the log. Put an LV on sdc1. Then remount again using this new LV as the log location. Then you can snap both XFS and the log, and mount the snap with the matching log.

Signature · 6 lines
Stan

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw
In reply to aurfalien
Quoted 11 lines · aurfalien

Hi all,

So I have an XFS file system within LVM which has an external log.

My mount option in FSTAB is;

/dev/vg_spock_data/lv_data /data xfs logdev=/dev/sdc1,nobarrier,logbufs=8,noatime,nodiratime 1 1

All is well no issues and very fast.

Now I'd like to snapshot this bad boy and then run rsnapshot to create a few days backup.

You need to snapshot the log device as well.

But that is problematic in that you need to snapshot it at the same time you snapshot the data volume. Hence yo'd have to do:

# xfs_freeze -f <filesystem>
# <snapshot data volume>
# <snapshot log volume>
# xfs_freeze -u <filesystem>

And now you can mount the snapshot with:

# mount /dev/vg_spock_data/datasnapshot /snapshot -o nouuid,ro,logdev=/dev/vg_spock_log/logsnapshot

If you can't snapshot the log device, then you can't snapshot the filesystem. Yet another reason for using internal logs...

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#4 lore raw
Quoted 23 lines · Dave Chinner
Quoted 11 lines · aurfalien

Hi all,

So I have an XFS file system within LVM which has an external log.

My mount option in FSTAB is;

/dev/vg_spock_data/lv_data /data xfs logdev=/dev/sdc1,nobarrier,logbufs=8,noatime,nodiratime 1 1

All is well no issues and very fast.

Now I'd like to snapshot this bad boy and then run rsnapshot to create a few days backup.

You need to snapshot the log device as well.

But that is problematic in that you need to snapshot it at the same time you snapshot the data volume. Hence yo'd have to do:

# xfs_freeze -f <filesystem>
# <snapshot data volume>
# <snapshot log volume>
# xfs_freeze -u <filesystem>
Quoted 6 lines

And now you can mount the snapshot with:

# mount /dev/vg_spock_data/datasnapshot /snapshot -o nouuid,ro,logdev=/dev/vg_spock_log/logsnapshot

If you can't snapshot the log device, then you can't snapshot the filesystem. Yet another reason for using internal logs...

Hm, given that freezing the fs makes the log (almost) completely clean, I wonder if he could mount with /dev/zero (or a loopback 0-filled file) to get at the snapshot, especially since it's being mounted RO.

Should be safe & consistent, no?

i.e.

truncate --size=2g logfile (or however big it needs to be)
losetup /dev/loop0 logfile
mount /dev/vg_anette_data/datasnapshot /snapshot -o logdev=/dev/loop0,nouuid,ro

-Eric

Quoted 4 lines

Cheers,

Dave.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#5 lore raw
Quoted 28 lines · Eric Sandeen
Quoted 27 lines · Dave Chinner
Quoted 11 lines · aurfalien

Hi all,

So I have an XFS file system within LVM which has an external log.

My mount option in FSTAB is;

/dev/vg_spock_data/lv_data /data xfs logdev=/dev/sdc1,nobarrier,logbufs=8,noatime,nodiratime 1 1

All is well no issues and very fast.

Now I'd like to snapshot this bad boy and then run rsnapshot to create a few days backup.

You need to snapshot the log device as well.

But that is problematic in that you need to snapshot it at the same time you snapshot the data volume. Hence yo'd have to do:

# xfs_freeze -f <filesystem>
# <snapshot data volume>
# <snapshot log volume>
# xfs_freeze -u <filesystem>

And now you can mount the snapshot with:

# mount /dev/vg_spock_data/datasnapshot /snapshot -o nouuid,ro,logdev=/dev/vg_spock_log/logsnapshot
Quoted 8 lines
Quoted 2 lines

If you can't snapshot the log device, then you can't snapshot the filesystem. Yet another reason for using internal logs...

Hm, given that freezing the fs makes the log (almost) completely clean, I wonder if he could mount with /dev/zero (or a loopback 0-filled file) to get at the snapshot, especially since it's being mounted RO.

Should be safe & consistent, no?

In theory. Never tried it myself.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
author
#6 lore raw
In reply to Eric Sandeen
Quoted 37 lines · Eric Sandeen
Quoted 23 lines · Dave Chinner
Quoted 11 lines · aurfalien

Hi all,

So I have an XFS file system within LVM which has an external log.

My mount option in FSTAB is;

/dev/vg_spock_data/lv_data /data xfs logdev=/dev/sdc1,nobarrier,logbufs=8,noatime,nodiratime 1 1

All is well no issues and very fast.

Now I'd like to snapshot this bad boy and then run rsnapshot to create a few days backup.

You need to snapshot the log device as well.

But that is problematic in that you need to snapshot it at the same time you snapshot the data volume. Hence yo'd have to do:

# xfs_freeze -f <filesystem>
# <snapshot data volume>
# <snapshot log volume>
# xfs_freeze -u <filesystem>
Quoted 6 lines

And now you can mount the snapshot with:

# mount /dev/vg_spock_data/datasnapshot /snapshot -o nouuid,ro,logdev=/dev/vg_spock_log/logsnapshot

If you can't snapshot the log device, then you can't snapshot the filesystem. Yet another reason for using internal logs...

Hm, given that freezing the fs makes the log (almost) completely clean, I wonder if he could mount with /dev/zero (or a loopback 0-filled file) to get at the snapshot, especially since it's being mounted RO.

Should be safe & consistent, no?

Quoted 7 lines

i.e.

truncate --size=2g logfile (or however big it needs to be)
losetup /dev/loop0 logfile
mount /dev/vg_anette_data/datasnapshot /snapshot -o logdev=/dev/loop0,nouuid,ro

-Eric

I'll try it and let you know.

Should be interesting.

- aurf
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

author
#7 lore raw
In reply to Eric Sandeen
Quoted 37 lines · Eric Sandeen
Quoted 23 lines · Dave Chinner
Quoted 11 lines · aurfalien

Hi all,

So I have an XFS file system within LVM which has an external log.

My mount option in FSTAB is;

/dev/vg_spock_data/lv_data /data xfs logdev=/dev/sdc1,nobarrier,logbufs=8,noatime,nodiratime 1 1

All is well no issues and very fast.

Now I'd like to snapshot this bad boy and then run rsnapshot to create a few days backup.

You need to snapshot the log device as well.

But that is problematic in that you need to snapshot it at the same time you snapshot the data volume. Hence yo'd have to do:

# xfs_freeze -f <filesystem>
# <snapshot data volume>
# <snapshot log volume>
# xfs_freeze -u <filesystem>
Quoted 6 lines

And now you can mount the snapshot with:

# mount /dev/vg_spock_data/datasnapshot /snapshot -o nouuid,ro,logdev=/dev/vg_spock_log/logsnapshot

If you can't snapshot the log device, then you can't snapshot the filesystem. Yet another reason for using internal logs...

Hm, given that freezing the fs makes the log (almost) completely clean, I wonder if he could mount with /dev/zero (or a loopback 0-filled file) to get at the snapshot, especially since it's being mounted RO.

Should be safe & consistent, no?

Quoted 8 lines

i.e.

truncate --size=2g logfile (or however big it needs to be)
losetup /dev/loop0 logfile
mount /dev/vg_anette_data/datasnapshot /snapshot -o logdev=/dev/loop0,nouuid,ro

-Eric

It worked!

After running your mount command above I get;

mount: you didn't specify a filesystem type for /dev/mapper/vg_anette_data-datasnapshot
I will try type xfs
/dev/mapper/vg_anette_data-datasnapshot on /snapshot type xfs (ro,logdev=/dev/loop0,nouuid)
mount: /snapshot does not contain SELinux labels.
You just mounted an file system that supports labels which does not contain labels, onto an SELinux box. It is likely that confined applications will generate AVC messages and not be allowed access to this file system. For more details see restorecon(8) and mount(8).

And the contents of the /snapshot dir matched the data volume files, size, etc...

Wow, how cool are you man, many thanks!!!!

I'm thinking of disabling selinux on this box at any rate which should remove the above message.

- aurf
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs