How to mount a usb disk in a lxc container? - linux

Here I created a lxc container in the host operating system, Ubuntu 22.04, whose os is the same as the host's, on a Raspberry Pi.
I want to access(r/w) files of a usb disk in the lxc container so I try to mount the device into the container following the tutorials found in the internet including some answers of questions in Stackoverflow. Sadly, all of them failed.
Here are the datails.
This is the usb device:
Bus 001 Device 007: ID 14cd:1212 Super Top microSD card reader (SY-T18)
I have mounted it into the host system.
As what those tutorials say, I add two sentences into the config of the instance of the lxc container as follows:
lxc.cgroup.devices.allow = c 189:* rwm
lxc.mount.entry = /dev/bus/usb/001/007 dev/bus/usb/001/007 none bind,optional,create=dir
And this is the whole config
lxc.rootfs.path = dir:/dockers/regular/rootfs
lxc.uts.name = regular
lxc.arch = armhf
# Network configuration
lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
lxc.net.0.hwaddr = 00:16:3e:61:b2:40
lxc.cgroup.devices.allow = c 189:* rwm
lxc.mount.entry = /dev/bus/usb/001/007 dev/bus/usb/001/007 none bind,optional,create=dir
Then I start the container and check out /dev, there is a directory /dev/bus/usb/001/007 (there's no such dir before I edit the config).
However, in the lxc container I couldn't find the usb device in /dev and it failed when I tried to mount the usb device via its name (like sda1) or UIID.
It means the config editing worked that I can find the /dev/bus/usb/001/007 in the container. But still I can't access the usb device.

Related

Vfio 0000:41:00.0: failed to open /dev/vfio/32: No such file or directory - QEMU

I have a NVME M.2 SSD that I would like to pass-through to my Virtual Machine as a boot, My SSD works fine with the Virtual Machine Manager, but when I attempt to the Qemu:Console, I get the following message Saying it is not a existing file?!
checked if it the pass-through worked!
This is the Qemu Console command I am using
-device vfio-pci,host=41:00.0
Reading on I found it was a QEMU Console Permission error. I can't find a way to set the vfio permission for manjaro, I heard something of setting a udev perms up, PCI Passthrough is working for other devices, Like my GT710 is working fine.
I then noticed that it was attached to the host and I could not find anyway to remove it, as seen here.
Please Help me!
You need bind your PCI device to the vfio-pci driver.
Unbind pci device from its previous driver
echo "0000:00:14.0" > /sys/devices/pci0000:00/0000:00:14.0/driver/unbind
Bind to vfio-pci driver
echo 8086 a36d > /sys/bus/pci/drivers/vfio-pci/new_id
Where 8086 is the vendor id of the PCI device, and a36d is device id of the PCI device
Check and vfio group should be present, and Qemu can run.
ls -l /dev/vfio/

Error Mounting for ntfs partition in ubuntu 16.04 in terminal

hello.
i need to help. i want to mounting drive D in ubuntu 16.04.BUT
my partition is ntfs format. (Drive C & D)
I had Installed Windows 7 on my computer, but then I Deleted It and Installed Ubuntu 16.04, but i just repartition the drive C. and did not change the drive D partition.
means that i changed C partitioning and partitioned it for Ubuntu OS(like home & swap & root). partition of D is constant. so D partitions did not change.(D partition is NTFS)
partitioning for ubuntu in C
When Ubuntu installed, i wanted to open my D drive (ntfs) but get the following error:
this message show when i want to open drive
and when mounting in terminal give me this message:
`root#mjb:/home/mjb# mount -t "ntfs" /home
Mount is denied because the NTFS volume is already exclusively opened.
The volume may be already mounted, or another software may use it which
could be identified for example by the help of the 'fuser' command.`
and this:
sudo mount -t ntfs-3g /dev/sda5 /dummy
[sudo] password for mjb:
The disk contains an unclean file system (0, 0).
Metadata kept in Windows cache, refused to mount.
Failed to mount '/dev/sda5': Operation not permitted
The NTFS partition is in an unsafe state. Please resume and shutdown
Windows fully (no hibernation or fast restarting), or mount the volume
read-only with the 'ro' mount option.
I test this solution:
open Terminal
type this command sudo -mount -t ntfs -r /dev/sda5 and then enter
then the partition mounted but i have a new problem:
the partition is read only because i type in command -r
ubuntu told me in the error message that: you can mount partition read only.
my question is: does exist any command for mounting partition in the form of read/write.
Open Disks
Select the partition you are not able to mount then turn off automatic mounting options, unselect mount at startup & write ro after comma as shown in the image & now you should be able to mount the disk succesfully.
seems like your windows is locking your HD before shutting down.
This happens when you try to acess the HD that windows is installed on from another OS, because on shutdown, windows locks the acess to the HD because by doing this, it can gain some performance on resuming Windows the next time you boot it.
So, simply try rebooting your windows before going to linux, if you shutdown Windows and then turn your PC directly into any other SO you wont be able to acess the HD/partition Windows has acess to.
Try Shift+shutdown in windows, then boot to Ubuntu os. It will mount all drives

Mount Netapp NFS share permanently on RHEL 6.4

I am trying to mount a volume on a RHEL 6.4 virtual machine permanently.
My fstab entry is as:
172.17.4.228:/bp_nfs_test1 /mnt1 nfs rsize=8192,wsize=8192,intr
And I mounted the volume as:
mount 172.17.4.228:/bp_nfs_test1 /mnt1
When I run df -h I can see the volume and able to access it properly.
But when I reboot the VM, the mount is gone and not able to access it anymore even though the entry in /etc/fstab is present
I have to manually mount the volume again (mount -a), then only I am able to see my volume in df -h and access it.
Any help is appreciated
The mount process on boot is very early, so your network won't be online thus preventing the nfs share from being mounted. You'll need to enable netfs, which manages network file shares, and runs after the network is up. Your desired process is:
Standard mounts processed.
NFS share is skipped during initial mounts (by adding _netdev to options).
After network is online, netfs will process network file systems like nfs and bring them online.
To prevent automounter for attempting to mount your nfs share before the network services are available, add _netdev to your options:
172.17.4.228:/bp_nfs_test1 /mnt1 nfs rsize=8192,wsize=8192,intr,_netdev
Enable netfs:
chkconfig netfs on
Alternatively, you could also configure the share through the /etc/auto.master configuration and have it mount when the share is accessed.

Run command after mount/unmout usb pen drive

I have Raspberry Pi (with Raspbian) and using it as DLNA/UPnP server and renderer. I run minidlna as DLNA server and i have some media files on USB.
I would like to automaticaly rebuild DLNA DB when drive is mounted and unmounted. This is done by command:
sudo service minidlna force-reload
Is threre any way how to autorun this command?
BTW I use "USBmount" package for automount USB drives.
Thanx
You can do this using the tool usbmount.
It has the possibility to add scripts that will be run on mount/umount events in /etc/usbmount/mount.d/ and /etc/usbmount/umount.d/.
Start by finding your device in lsusb. Note the ID (eg 12f5:a91a)
Create a new udev rules file in /etc/udev/rules.d/ eg /etc/udev/rules.d/100-my-mount.rules and write a new rule in there like this:
ACTION=="add", ATTRS{idVendor}=="12f5", ATTRS{idProduct}=="a91a", RUN+="/home/your_username/bin/my-mount-script.sh"
For unmounted device use ACTION=="remove" in rule and another script.

Linux - Kickstart stops with dialog about which networking device - how to avoid

Using a kickstart file that stops with a dialog "You have multiple
network devices on this system. Which one do you want to install through?"
The machine being configured with PXEboot has two Ethernet interfaces. What's
missing from the network entries below? I'd like this install to proceed
without asking which Ethernet interface.
PXE begins the install with DHCP, so Kickstart should already know which of
eth0, eth1, etc. to use.
Here is the Ethernet line in the ks.cfg file:
network --onboot yes --device eth0 --bootproto dhcp --noipv6
Any ideas appreciated.
NOTE: I have already tried the below option and it didn't work:
In pxelinux config file:
add ksdevice=bootif
also add "IPAPPEND 2" to the end of the file
In kickstart file, don't specify a device:
"network --bootproto dhcp"
How to force an kickstart installation to take place over a specific Ethernet device?
Maybe your network devices' names had been renamed, for example, em1, em2 ... in Dell servers.
In that case you can add biosdevname=0 to the kernel boot arguments, that will prevent biosdevname from being invoked.

Resources