[SOLVED] Trying to mount a partition from a hdd into an lxc debian container. can you guide me because this doesn't seem possible at all or i did this worng.

cyqpann

Member
Nov 18, 2021
25
0
6
44
Hi,

Mabye im doing this wrong or there an alternative, but they way i did is, i took my 3To hdd and gparted it in 3 xfs partitions. one of 2to, another one of 500g and the rest in another one. i really don't know if i done this properly but i need to split this hdd into 3 partitions and be able to use them into 3 different lxc container.

when i'm creating a brand new lxc container, i don't see it under Disks when i'm trying to add it. If i do this command, lsblk, i can see it under sdc.

root@wordpress00:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 10G 0 loop /
sda 8:0 0 223.6G 0 disk
|-sda1 8:1 0 1007K 0 part
|-sda2 8:2 0 512M 0 part
`-sda3 8:3 0 223.1G 0 part
sdb 8:16 0 223.6G 0 disk
|-sdb1 8:17 0 1007K 0 part
|-sdb2 8:18 0 512M 0 part
`-sdb3 8:19 0 223.1G 0 part
sdc 8:32 0 2.7T 0 disk
|-sdc1 8:33 0 1.9T 0 part
|-sdc2 8:34 0 313.9G 0 part
`-sdc3 8:35 0 490.9G 0 part

Is there a way to mount sdc1 as my /datafolder for my picture data storage that will eb used to host my raw fuiji pictures into my debian lxc? i will create 2 other lxc container and do the same for the sdc2 and sdc3. Either, i did this all wrong or i don't know what to research on the web, reddit or proxmox. im fairly new to linux world .

ty very much
 
Last edited:
Just add a mountpoint to the container? Something like adding mp0: /dev/sdc1,mp=/datafolder to the container configuration file could work. Note that you might want to use a path like /dev/disk/by-id/..., which is more stable, instead of /dev/sdc1.
 
Last edited:
i tried this option: but didn't work at all. #100 = wordpres00.domain.lan. after rebooting my host and my lxc container. the config dissapear and nothing is mount.


fstab option​

You probably want to use the fstab file:
$ cat /var/lib/lxc/100/fstab
/dev/sdc3 mnt/sdc xfs noatime 0 0

It's important that the mountpoint (2nd argument) doesn't begin with a slash, otherwise the LXC script tries to mount the filesystem in the host os.
On Ubuntu, the file should aready exist but empty. If not, just create it and make sure you have the following line in your config file:
$ grep fstab /var/lib/lxc/100/config
lxc.mount = /var/lib/lxc/100/fstab

device option​

If you really need access to your device, you can make it available in your container:
$ grep devices /var/lib/lxc/100/config
lxc.cgroup.devices.allow = b 8:33 rwm

This will make /dev/sdc1 available in your container (8:33 is the block device major:minor).
But this will not be enough. Your container normally doesn't have the permission to mount any file system. You will need to use the following line or a similar trick too:
$ grep profile /var/lib/lxc/100/config
lxc.aa_profile = unconfined
 
Just add a mountpoint to the container? Something like adding mp0: /dev/sdc1,mp=/datafolder to the container configuration file could work. Note that you might want to use a path like /dev/disk/by-id/.../ICODE], which is more stable, instead of [ICODE]/dev/sdc1.
trying this atm !!!
 
If you want to share a partition with more than one container: mount the /dev/sdc1 partition on a directory on the Proxmox host using /etc/fstab (for example /srv/datafolder) and bind-mount the directory to every container (instead of /dev/sdc1)
 
what i've done so far and it didnt seem to work unless i messed up :/

ls -l /dev/disk/by-id/

lrwxrwxrwx 1 root root 9 May 4 15:37 ata-ST3000DM001-1ER166_Z500GTK3 -> ../../sdc
lrwxrwxrwx 1 root root 10 May 4 15:37 ata-ST3000DM001-1ER166_Z500GTK3-part1 -> ../../sdc1
lrwxrwxrwx 1 root root 10 May 4 15:37 ata-ST3000DM001-1ER166_Z500GTK3-part2 -> ../../sdc2
lrwxrwxrwx 1 root root 10 May 4 15:37 ata-ST3000DM001-1ER166_Z500GTK3-part3 -> ../../sdc3
lrwxrwxrwx 1 root root 9 May 4 15:37 wwn-0x5000c5007970957f -> ../../sdc
lrwxrwxrwx 1 root root 10 May 4 15:37 wwn-0x5000c5007970957f-part1 -> ../../sdc1
lrwxrwxrwx 1 root root 10 May 4 15:37 wwn-0x5000c5007970957f-part2 -> ../../sdc2
lrwxrwxrwx 1 root root 10 May 4 15:37 wwn-0x5000c5007970957f-part3 -> ../../sdc3
lrwxrwxrwx 1 root root 9 May 4 15:37 wwn-0x50026b73802cf245 -> ../../sda
lrwxrwxrwx 1 root root 10 May 4 15:37 wwn-0x50026b73802cf245-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 May 4 15:37 wwn-0x50026b73802cf245-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 May 4 15:37 wwn-0x50026b73802cf245-part3 -> ../../sda3
lrwxrwxrwx 1 root root 9 May 4 15:37 wwn-0x50026b7682de7091 -> ../../sdb
lrwxrwxrwx 1 root root 10 May 4 15:37 wwn-0x50026b7682de7091-part1 -> ../../sdb1
lrwxrwxrwx 1 root root 10 May 4 15:37 wwn-0x50026b7682de7091-part2 -> ../../sdb2
lrwxrwxrwx 1 root root 10 May 4 15:37 wwn-0x50026b7682de7091-part3 -> ../../sdb3

then

lshw -class disk -class storage

*-disk:2
description: ATA Disk
product: ST3000DM001-1ER1
physical id: 0.0.0
bus info: scsi@5:0.0.0
logical name: /dev/sdc
version: CC25
serial: Z500GTK3
size: 2794GiB (3TB)
capabilities: gpt-1.00 partitioned partitioned:gpt
configuration: ansiversion=5 guid=e0072430-2366-4c35-bdff-1e00cbdd4581 logicalsectorsize=512 sectorsize=409

qm set 100 -scsi2 /dev/disk/by-id/ata-ST3000DM001-1ER166_Z500GTK3-part1

and the answer:

Configuration file 'nodes/SammyServer/qemu-server/100.conf' does not exist

Something wrong i've done?
 
you have an idea of what i should write because it doesnt seem to work. even if i need to create a folder on this partition and reformat it, it would really help a lot because nothing seem to work.
Create a directory on the Proxmox host to mount the partition to: mkdir /srv/datafolder. Then mount the partition on the Proxmox host: mount /dev/disk/by-id/ata-ST3000DM001-1ER166_Z500GTK3-part1 /srv/datafolder. Check if you see the expected files in /srv/datafolder on the Proxmox host. If you want the system to do this automatically in the future, change /etc/fstab on the Proxmox host accordingly.
Shutdown the container. Find the container configuration file on the Proxmox host in the /etc/pve/lxc/ directory and add to the configuration file this line: mp0: /srv/datafolder,mp=/datafolder. Start the container and check if you see the expected files in the /datafolder inside the container.
You might have to change the owner and permissions of /srv/datafolder on the Proxmox host depending on the user inside the container.
 
  • Like
Reactions: puncake
i created the folder on the host mkdir /srv/datafolder
then mount /dev/disk/by-id/ata-ST3000DM001-1ER166_Z500GTK3-part1 /srv/datafolder
mount: /srv/datafolder: wrong fs type, bad option, bad superblock on /dev/sdc1, missing codepage or helper program, or other error.
 
i created the folder on the host mkdir /srv/datafolder
then mount /dev/disk/by-id/ata-ST3000DM001-1ER166_Z500GTK3-part1 /srv/datafolder
mount: /srv/datafolder: wrong fs type, bad option, bad superblock on /dev/sdc1, missing codepage or helper program, or other error.
Did you format the partition with a filesystem? Otherwise use mkfs.ext4 /dev/disk/by-id/ata-ST3000DM001-1ER166_Z500GTK3-part1 to create a Linux filesystem.
 
omg, thanks a lot for the time you took, everything is working like i want. thanks a lot ! wow that look so simple for you ty ty ty !
i copied mount /dev/disk/by-id/ata-ST3000DM001-1ER166_Z500GTK3-part1 /srv/datafolder into the /etc/fstab file incase the host restart.
 
i copied mount /dev/disk/by-id/ata-ST3000DM001-1ER166_Z500GTK3-part1 /srv/datafolder into the /etc/fstab file incase the host restart.
Don't put mount /dev/disk/by-id/ata-ST3000DM001-1ER166_Z500GTK3-part1 /srv/datafolder in /etc/fstab; that won't work. It needs to use the fstab syntax:
/dev/disk/by-id/ata-ST3000DM001-1ER166_Z500GTK3-part1 /srv/datafolder ext4 default 0 2

EDIT: For future reference: default should be defaults instead.
 
Last edited:
  • Like
Reactions: cyqpann
Don't put mount /dev/disk/by-id/ata-ST3000DM001-1ER166_Z500GTK3-part1 /srv/datafolder in /etc/fstab; that won't work. It needs to use the fstab syntax:
/dev/disk/by-id/ata-ST3000DM001-1ER166_Z500GTK3-part1 /srv/datafolder ext4 default 0 2
ahhhh lol.. thanks a lot !! a thousand thx !!!
 
Don't put mount /dev/disk/by-id/ata-ST3000DM001-1ER166_Z500GTK3-part1 /srv/datafolder in /etc/fstab; that won't work. It needs to use the fstab syntax:
/dev/disk/by-id/ata-ST3000DM001-1ER166_Z500GTK3-part1 /srv/datafolder ext4 default 0 2
hey thanks for the command, but i think it didnt work at all. when i rebooted the host, i had a message that i can't mount /dev/disk and i wasnt able to access any of my host in my datacenter until i do control D to repair, thing that didnt work. So i had to login via physical access and remove the line into /etc/fstab and do a systemctl reboot. then everything works normally

edited my typo errors
 
Last edited:
hey thanks for the command, but i think it didnt work at all. when i rebooted the host, i had a message that i can't mount /dev/disk and i wasnt able to access any of my host in my datacenter until i do control D to repair, thing that didnt work. So i had to login via physical access and remove the line into /etc/fstab and do a systemctl reboot. then everyone work normally
I'm sorry for the trouble I caused you. Maybe there is something wrong with the line I proposed. If you stop the container(s), unmount the partion, add the line again and then type mount /srv/datafolder (mount will look in /etc/fstab for the information needed). What errors do you get? (This is the way to test changes to /etc/fstab, as far as I know.)
 
Last edited:
I'm sorry for the trouble I caused you. Maybe there is something wrong with the line I proposed. If you stop the container(s), unmount the parition, add the line again and then type mount /srv/datafolder (mount will look in /etc/fstab for the information needed). What errors do you get?
hehe, don't worry at all. it all fine. your'e kind enough to help me. do not worry for this lol.

so what i've done in this order. i stop my lxc container , i deleted the mapping we did. then i went on the host and i did nano /etc/fstab

i add at the end of the files: /dev/disk/by-id/ata-ST3000DM001-1ER166_Z500GTK3-part1 /srv/datafolder ext4 default 0 2

I press ctrl+ s and ctrl + x, i did systemctl reboot

ext4-fs sdc1 unreconized mount option " default " or missing value
[FAILED] failed to mount /srv/datafolder
[DEPEND] dependency failed for local files systems.
 
You don't need to reboot or run systemd command. Just make changes to /etc/fstab and try to mount the directory. My mistake was default should be defaults (with an s at the end). See The fourth field in fstab for more information and options.
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!