Use 2nd (Second) drive as backup drive

syssu

New Member
Apr 23, 2011
9
0
1
OK I have searched both google and this forum but have found some stuff close to what I need but not an exact answer. First Id like to state that I'm very new to the linux environment so I need a step-by-step guidance to complete this task.

What I have setup is a computer with 2 hard drives. 1 is a 1TB drive and another is a 2TB drive. Everything is currently installed on the 1TB drive and I would like to use the 2nd 2TB drive as strictly for backups. So far I know the following;

- 2TB (that i want to use for backup) is /dev/sda
- 1TB (with everything install on as of now) is /dev/sdb
- I created a 2nd LVM and added the 2TB drive but in the proxmox disk setup I can only choose to use it vm disks and not as backups.

Thank you in advance!
 
OK I have searched both google and this forum but have found some stuff close to what I need but not an exact answer. First Id like to state that I'm very new to the linux environment so I need a step-by-step guidance to complete this task.

What I have setup is a computer with 2 hard drives. 1 is a 1TB drive and another is a 2TB drive. Everything is currently installed on the 1TB drive and I would like to use the 2nd 2TB drive as strictly for backups. So far I know the following;

- 2TB (that i want to use for backup) is /dev/sda
- 1TB (with everything install on as of now) is /dev/sdb
- I created a 2nd LVM and added the 2TB drive but in the proxmox disk setup I can only choose to use it vm disks and not as backups.

Thank you in advance!
Hi,
you are sure that your pve-installation is on sdb? Normaly the first disk - sda is used!

For backup you need a filesystem. lvm give you space for logical volumes (which can contains filesystem, or raw-devices or whatever).
You have two choices.
1. remove lvm from second disk and create a normal (e.g. ext4) filesystem (partition-type 83).
2. (which i prefer) simply create an logical volume on your lvm for backup - this has the effort you can play also with VM-disks on lvm, because you don't need to use all space for backup in the beginning - logical volumes can grow whithout trouble.

For 2:
Code:
lvcreate -L 1T -n backup name_of_VG    # create an logical volume with 1TB on the volumegroup name_of_VG

#have a look:
vgdisplay
lvdisplay

mkfs.ext4 /dev/name_of_VG/backup
mkdir /backup
echo "/dev/name_of_VG/backup /backup ext4 defaults 0 2" >> /etc/fstab     # appends this line to fstab
mount /backup
after that, define the directory /backup as backup-storage.

To expand the logical volume see "man lvm", "man lvextend" and "man resize2fs".

Udo
 
you are sure that your pve-installation is on sdb? Normaly the first disk - sda is used!
That is what I thought too and i tripple checked it because it was so confusing and did not match anything I read on the internet. But if I do an fdisk /dev/sdb it shows <1000GB and if i do fdisk /dev/sda it shows 2000GB meaning it has to be that way...also I just put in the 2TB drive today, after the install. It also said it was a GPT partition on the /dev/sda from when it was in my mac...

let me try what you have listed and ill report back, thank you!
 
OK, I did the command vgdisplay and got this for the 2nd LVM i created with the 2TB drive.


Code:
--- Volume group ---
  VG Name               second-lvm
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               1.82 TB
  PE Size               4.00 MB
  Total PE              476932
  Alloc PE / Size       204800 / 800.00 GB
  Free  PE / Size       272132 / 1.04 TB
  VG UUID               tWCzBC-V2Wl-gduN-zNcJ-WGQF-F9PD-FaKkxf

So i tried to run the following line and got the following error. any ideas?

Code:
proxmox:~# mkfs.ext4 /dev/second-lvm/backup
mke2fs 1.41.3 (12-Oct-2008)
Could not stat /dev/second-lvm/backup --- No such file or directory

The device apparently does not exist; did you specify it correctly?
 
OK, I did the command vgdisplay and got this for the 2nd LVM i created with the 2TB drive.


Code:
--- Volume group ---
  VG Name               second-lvm
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               1.82 TB
  PE Size               4.00 MB
  Total PE              476932
  Alloc PE / Size       204800 / 800.00 GB
  Free  PE / Size       272132 / 1.04 TB
  VG UUID               tWCzBC-V2Wl-gduN-zNcJ-WGQF-F9PD-FaKkxf
So i tried to run the following line and got the following error. any ideas?

Code:
proxmox:~# mkfs.ext4 /dev/second-lvm/backup
mke2fs 1.41.3 (12-Oct-2008)
Could not stat /dev/second-lvm/backup --- No such file or directory

The device apparently does not exist; did you specify it correctly?
Hi,
about sda and sdb:
you installed with only one hdd (thats ok). the first hdd is sda. After that you put the second hdd, but at the device-order (on the bus) the second hdd is before the pve-hdd, so after reboot the pve-hdd became sdb.
Perhaps you can change the order in the bios, or switch the slot. Its better to be sure, that grub installed on the right hdd.

about lvm:
please give the output of
Code:
lvdisplay
ls -l /dev/mapper

Udo
 
Hi,
about sda and sdb:
you installed with only one hdd (thats ok). the first hdd is sda. After that you put the second hdd, but at the device-order (on the bus) the second hdd is before the pve-hdd, so after reboot the pve-hdd became sdb.
Perhaps you can change the order in the bios, or switch the slot. Its better to be sure, that grub installed on the right hdd.

If i change it back to how it is suppose to be will that mess up anything?

about lvm:
please give the output of
Code:
lvdisplay
ls -l /dev/mapper

Udo

Sorry took so long i was asleep
Code:
proxmox:~# ls -l /dev/mapper
total 0
crw-rw---- 1 root root  10, 62 Apr 22 13:53 control
brw-rw---- 1 root disk 254,  2 Apr 22 13:53 pve-data
brw-rw---- 1 root disk 254,  1 Apr 22 13:53 pve-root
brw-rw---- 1 root disk 254,  0 Apr 22 13:53 pve-swap
brw-rw---- 1 root disk 254,  3 Apr 22 21:00 second--lvm-vm--102--disk--1
 
If i change it back to how it is suppose to be will that mess up anything?
Hi,
changing back should be not a problem. Because, the lvm-volumes finds itself and /boot is assign with UUID.
Sorry took so long i was asleep
Code:
proxmox:~# ls -l /dev/mapper
total 0
crw-rw---- 1 root root  10, 62 Apr 22 13:53 control
brw-rw---- 1 root disk 254,  2 Apr 22 13:53 pve-data
brw-rw---- 1 root disk 254,  1 Apr 22 13:53 pve-root
brw-rw---- 1 root disk 254,  0 Apr 22 13:53 pve-swap
brw-rw---- 1 root disk 254,  3 Apr 22 21:00 second--lvm-vm--102--disk--1
ahh,
you dont have a lv named backup - only a disk of the vm with the VMID 102.
I guess, there wasn't enough free space to create the backup-lv.
But with "vgdisplay" you see the free space... but it's show 1.04TB - should fit... perhaps something else wrong?
try this to use most of the space:
Code:
lvcreate -l 270000 -n backup /dev/second-lvm
One disadvantage has the solution with Backup and VM-lvm on one lvm: you can run in trouble with backup in snapshot-mode, because both on the same lvm...

Udo
 
I deleted the disk for the VM and removed the lvm from proxmox and now it says for the 2tb drive...notice the free space

Code:
  --- Volume group ---
  VG Name               second-lvm
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               1.82 TB
  PE Size               4.00 MB
  Total PE              476932
  Alloc PE / Size       0 / 0   
  Free  PE / Size       476932 / 1.82 TB
  VG UUID               tWCzBC-V2Wl-gduN-zNcJ-WGQF-F9PD-FaKkxf

So what do I need to type to get the backup running now? also the ls-l/dev/mapper now displays the following

Code:
proxmox:~# ls -l /dev/mapper
total 0
crw-rw---- 1 root root  10, 62 Apr 23 17:56 control
brw-rw---- 1 root disk 254,  2 Apr 23 17:56 pve-data
brw-rw---- 1 root disk 254,  1 Apr 23 17:56 pve-root
brw-rw---- 1 root disk 254,  0 Apr 23 17:56 pve-swap

Thank you in advance!
 
I deleted the disk for the VM and removed the lvm from proxmox and now it says for the 2tb drive...notice the free space

Code:
  --- Volume group ---
  VG Name               second-lvm
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               1.82 TB
  PE Size               4.00 MB
  Total PE              476932
  Alloc PE / Size       0 / 0   
  Free  PE / Size       476932 / 1.82 TB
  VG UUID               tWCzBC-V2Wl-gduN-zNcJ-WGQF-F9PD-FaKkxf
So what do I need to type to get the backup running now? also the ls-l/dev/mapper now displays the following

Code:
proxmox:~# ls -l /dev/mapper
total 0
crw-rw---- 1 root root  10, 62 Apr 23 17:56 control
brw-rw---- 1 root disk 254,  2 Apr 23 17:56 pve-data
brw-rw---- 1 root disk 254,  1 Apr 23 17:56 pve-root
brw-rw---- 1 root disk 254,  0 Apr 23 17:56 pve-swap
Thank you in advance!
Hi,
have you tried my example before?

lvcreate -l 270000 -n backup /dev/second-lvm
ls -l /dev/mapper
mkfs.ext4 /dev/second-lvm/backup
Udo
 
I did not try it before because I was not sure if everything would still apply seeing how I ade the changes. I went ahead and ran it and everything seemed to turn out just fine on the SSH end but what do I need to do to create the backups part on proxmox?

For example i tried to go to storage>Add LVM, but it does not show the backups one i created.
 
I did not try it before because I was not sure if everything would still apply seeing how I ade the changes. I went ahead and ran it and everything seemed to turn out just fine on the SSH end but what do I need to do to create the backups part on proxmox?

For example i tried to go to storage>Add LVM, but it does not show the backups one i created.

Had to run the last little bit of commands

Code:
mkdir /backup
echo "/dev/name_of_VG/backup /backup ext4 defaults 0 2" >> /etc/fstab     # appends this line to fstab
mount /backup

One thing I noticed is it only takes up around 985GB of space for the backup, is that because of the command lvcreate -l 270000 -n backup /dev/second-lvm and what in the command made it do that so i can understand what is going on.
 
Had to run the last little bit of commands

Code:
mkdir /backup
echo "/dev/name_of_VG/backup /backup ext4 defaults 0 2" >> /etc/fstab     # appends this line to fstab
mount /backup
One thing I noticed is it only takes up around 985GB of space for the backup, is that because of the command lvcreate -l 270000 -n backup /dev/second-lvm and what in the command made it do that so i can understand what is going on.
Hi,
with "-l" you give the amount of logical extends - in your case one extend is 4MB in size.
Look with "vgdisplay" how much do you have free. You can use "lvextend -l +XXXX" for extends, or "-L +800M" for MB.
After that use simply resize2fs.
Do an "df -k" before and after that.

Udo
 
Thank you very much you were very helpful! Looks like everything is setup and running. Ill know at 00:00 24 hours if it worked for sure, thank you again!
 
I used udo’s Option 1 and did the following and it worked.
For Dummies like me I’ve put it in as simple english as possible.

#Identify local disk to be used as backup drive via proxmox ssh console
fdisk -l
# In our case dev/sdc was intended for the local backup drive.

# format and prepare disk for mounting
cfdisk /dev/sdc
create Primary partition and Write and Quit
mkfs.ext4 /dev/sdc1
# don’t forget the number 1 at the end of the command or you will be banging your head on the desk for several hours wondering why its not working

# Manually mount disk to test that it can be mounted
mount -t ext4 /dev/sdc1 /mnt/backup

# goto proxmox web interface to setup local proxmox backup directory
Select Datacenter folder
Select Storage tab
Click Add | Directory
ID: local_backup_2TB (note - this can be what ever you want it to be)
Directory: /mnt/backup
Content: Backups
OK

# Go back to ssh console to configure backup disk to mount automatically on boot:
nano /etc/fstab

#append following to fstab file (note lines starting with # are used for comments and are ignored)
# automount internal 2TB backup disk
/dev/sdc1 /mnt/backup ext4 defaults 0 2

Ctrl-X to quit and Y to save changes

Reboot to test that you can see the local_backup_2TB Directory in web interface and that directory Status is Active
 
  • Like
Reactions: cscheat and Bardock