I have Centos on my physical drive.
new volume created like commands below:
dd if=/dev/zero of=cinder-volumes bs=1 count=0 seek=50G
losetup /dev/loop3 cinder-volumes
fdisk /dev/loop3
n
p
1
ENTER
ENTER
t
8e
w
pvcreate /dev/loop3
All things goes right and I was happy.
but after reboot, this volume missed.
whats is the problem?
thanks
You can associate the /dev/loop3 with cinder-volumes files as using /etc/rc.d/rc.local conf.
CentOS 6 or less
# vim /etc/rc.d/rc.local
mknod -m 660 /dev/loop3 b 7 3
losetup /dev/loop3 /path/to/cinder-volumes
CentOS 7
# vim /etc/rc.d/rc.local
mknod -m 660 /dev/loop3 b 7 3
losetup /dev/loop3 /path/to/cinder-volumes
After modifying, you set the execution flag to /etc/rc.d/rc.local
# chmod u+x /etc/rc.d/rc.local
And more checks your OS rc-local.service as following,
# systemctl list-unit-files rc-local.service
UNIT FILE STATE
rc-local.service static
or
UNIT FILE STATE
rc-local.service disable
If the state is disable, you can be enable the rc-local service, but the state is static is not any more conf.
# systemctl enable rc-local.service
Updated: Adding restore steps based on hypothesis that refer from questions.
★★★In advance, I defined that these steps are just written as the provision of information, I won't be not responsible for data-loss caused by these steps.★★★
Prepare the other server having same specifications as possible as you can.
backup the data (here is cinder-volumes file) with dd or cp commands
check the backup file whether same original data with md5sum command.
the backup data transfer to the new server for testing.
test command; losetup /dev/loop3 /path/to/cinder-volumes and blkid command for check UUID whether same with the original loop3 device.
More tests was always conducted on the new server, not production or important environments.
the loop3 or loopN device is virtual device for using the non-block device as of block device. It is just mapping interfaces. The loop3 device is disappeared but if cinder-volumes is clear, no problem.
I hope you it's helpful.
Related
I am trying to mount a file that will act as a read/write HFS+ filesystem. I am using arch linux based distro so I installed hfsprogs and hfsutils. In debian based distros hfsprogs should be enough.
I created a 8G file like this:
dd if=/dev/zero of=test.img bs=1024 count=0 seek=$[1000*8000]
Then I did the formatting:
mkfs.hfsplus -v TestImg test.img
After that when I try to mount the file I get:
mkdir /tmp/sun
sudo mount -t hfsplus -o loop,rw,offset=0 test.img /tmp/sun
mount: /tmp/sun: mount failed: Operation not permitted
Parted shows that offset it ok:
sudo parted -m test.img unit B print
1:0B:8191999999B:8192000000B:hfs+::;
I also tried to use fdisk with the file creating sun partition table but that did not help either. Can you help me please with creating HFS+ rw filesystem as a file?
I used loop device inappropriately.
The correct steps are:
Create file
dd if=/dev/zero of=test.img bs=100MB count=10 seek=$[10*8]
Create blocked device mapped to that file:
losetup -fP test.img
At this point blocked device /dev/loop0 got created.
Create filesystem:
mkfs.hfsplus test.img
Mount to your folder
mount -o rw,loop /dev/loop0 /tmp/loop_test
There are 2 pi in this setup:
- PI-domo: running domoticz
- PI-pump: controlling a pump with one GPIO
Those pi are far away, but can communicate through network. PI-domo has some passwordless ssh login setup to pi-pump, and contains three scripts:
- pump_on.sh: sends value to gpio with ssh to turn pump on and returns 1
`ssh pi#pi-pump -n "echo 0 > /sys/class/gpio/gpio18/value" && echo 1`
pump_off.sh: sends value to gpio with ssh to turn pump off and returns 0
ssh pi#pi-pump -n "echo 1 > /sys/class/gpio/gpio18/value" && echo 0
pump_status.sh: returns 1 if pump is on, 0 if pump is off.
All three scripts work as expected when launched in bash, but I can not find how to call them with domoticz. I created a virtual switch and set those as script:///.....[on off].sh but domoticz doesn't seem to be running any of them. nor could I find a place to read the status...
Any idea or link to a RECENT (working) tutorial would be welcome!
Found the issue: stupid me.
It turns out domoticz process was running as root and root didn't have the key setup for passwordless ssh.
I know that this is a old thread and it is answered already, but I have stumbled on the same issue and found that online answers lacked detail. So, here it goes:
On PI-domo run
sudo su to become root
Generate a new key using ssh-keygen -t rsa -b 4096 -C "nameofyourkey"
Copy your key to PI-pump by using ssh-copy-id -i /root/.ssh/yourkey.pub pi#pi-pump
ssh to pi-pump to test that ssh agent for root is working, and if all is well exit and go back to become a pi user.
Note 1: Although logging in as root of PI-domo, it is critical that pump_off and pump_status.sh contain pi#pi-pump and not root#pi-pump or this approach will fail.
Note 2: Domoticz log indicates that the above process has some error by outputting Error: Error executing script command (/home/pi/domoticz/scripts/pump_off.sh). returned: 65280. Note the 65280 error in particular
I have a single vmware disk image file with vmdk extension
I am trying to mount this and explore all of the partitions (including hidden ones).
I've tried to follow several guides, such as : http://forums.opensuse.org/showthread.php/469942-mounting-virtual-box-machine-images-host
I'm able to mount the image using vdfuse
vdfuse -w -f windows.vmdk /mnt/
After this I can see one partition and an entire disk exposed
# ll /mnt/
total 41942016
-r-------- 1 te users 21474836480 Feb 28 14:16 EntireDisk
-r-------- 1 te users 1569718272 Feb 28 14:16 Partition1
Continuing with the guide I try to mount either EntireDisk or Partition1 using
mount -o loop,ro /mnt/Partition1 mnt2/
But that gives me the error 'mount: you must specify a filesystem type'
In trying to find the correct type I tried
dd if=/mnt/EntireDisk | file -
which outputs a ton of information but of note is:
/dev/stdin: x86 boot sector; partition 1: ....... FATs ....
So i tired to mount as a vfat but that gave me
mount: wrong fs type, bad option, bad superblock ...etc
What am I doing wrong?
For newer Linux systems, you can use guestmount to mount the third partition within a VMDK image:
guestmount -a xyz.vmdk -m /dev/sda3 --ro /mnt/vmdk
Alternatively, to autodetect and mount an image (less reliable), you can try:
guestmount -a xyz.vmdk -i --ro /mnt/vmdk
Do note that the flag --ro simply mounts the image as read-only; to mount the image as read-write, just replace it with the flag --rw.
Installation
guestmount is contained in following packages per distro:
Ubuntu: libguestfs-tools
OpenSuse: guestfs-tools
CentOS / Fedora: libguestfs-tools-c
Troubleshooting
error: could not create appliance through libvirt
$ guestmount -a file.vmdk -i --ro /mnt/guest
libguestfs: error: could not create appliance through libvirt.
Try running qemu directly without libvirt using this environment variable:
export LIBGUESTFS_BACKEND=direct
Original error from libvirt: Cannot access backing file '/path/to/file.vmdk' of storage file '/tmp/libguestfssF6WKX/overlay1.qcow2' (as uid:107, gid:107): Permission denied [code=38 int1=13]
Solution: use LIBGUESTFS_BACKEND=direct, as suggested:
LIBGUESTFS_BACKEND=direct guestmount -a file.vmdk -i --ro /mnt/guest
fusermount: user has no write access to mountpoint
LIBGUESTFS_BACKEND=direct guestmount -a file.vmdk -i --ro /mnt/guest/
fusermount: user has no write access to mountpoint /mnt/guest
libguestfs: error: fuse_mount failed: /mnt/guest/, see error messages above
Solution: use sudo, or change file permissions on the mountpoint
You can also use qemu:
For .vdi disks
sudo modprobe nbd
sudo qemu-nbd -c /dev/nbd1 ./linux_box/VM/image.vdi
if they are not installed, you can install them (issuing this command in Ubuntu)
sudo apt install qemu-utils
and then mount it with:
mount /dev/nbd1p1 /mnt
For .vmdk disks
sudo modprobe nbd
sudo qemu-nbd -r -c /dev/nbd1 ./linux_box/VM/image.vmdk
notice that I use the option -r, that's because VMDK version 3 must be read only to be able to be mounted by qemu
and then I mount it with
mount /dev/nbd1p1 /mnt
I use nbd1, because nbd0 sometimes gives: 'mount: special device /dev/nbd0p1 does not exist'
For .ova disks
tar -tf image.ova
tar -xvf image.ova
The above will extract the .vmdk disk and then mount it.
Install affuse, then mount using it.
affuse /path/file.vmdk /mnt/vmdk
The raw disk image is now found under /mnt/vmdk.
Check its sector size:
fdisk -l /mnt/vmdk/file.vmdk.raw
# example
Disk file.vmdk.raw: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000da525
Device Boot Start End Sectors Size Id Type
/mnt/vmdk/file.vmdk.raw1 * 2048 41943039 41940992 20G 83 Linux
Multiply sector size and start sector. In the example it would be 2048*512:
echo '2048*512' | bc
1048576
Mount the raw file using that offset:
mount -o ro,loop,offset=1048576 /mnt/vmdk/file.raw /mnt/vmdisk
The disk should now be mounted and readable on /mnt/vmdisk.
Here is an answer from commandlinefu.com that worked for me:
kpartx -av <image-flat.vmdk>; mount -o /dev/mapper/loop0p1 /mnt/vmdk
You can also activate LVM volumes in the image by running
vgchange -a y
and then you can mount the LV inside the image.
To unmount the image, umount the partition/LV, deactivate the VG for the image
vgchange -a n <volume_group>
then run
kpartx -dv <image-flad.vmdk>
to remove the partition mappings.
You can take a look in this article for a download link for VMware Virtual Disk Development Kit (VDDK). Once downloaded and installed:
vmware-mount -p path_to_vmdk will show the partitions inside the VMDK file. For example:
Nr Start Size Type Id Sytem
-- ---------- ---------- ---- -- ------------------------
1 2048 461371392 BIOS 83 Linux
Then just do:
sudo vmware-mount path_to_vmdk 1 /mnt/mount_point
I tried guestmount, but it is very, very slow. Underneath it creates a virtual machine, uses KVM and so on. Crazy stuff, slow as hell.
Have you got the software package for ntfs?
Try
apt-get install ntfs-3g
on debian based systems.
I have an error while i want to copy my file in centos 6.5 using samba to my windows 7 folder.
This is the error message :
you need permission to perform this action
You require permission from ERP\hao to make change to this file.
[global]
workgroup = MYGROUP
server string = Samba Server Version %v
log file = /var/log/samba/log.%m
# max 50KB per log file, then rotate
max log size = 50
security = user
[erp]
comment = ERP
path = /opt/erp
public = yes
writable = yes
printable = no
browseable = no
create mask = 0777
create mode = 0777
directory mode = 0777
share modes = yes
force user = hao
force group = hao
read only = no
File that i want to copy location :
/opt/erp/mve
my samba path
/opt/erp
[hao#erp mve]$ stat -c '%a %n' *
777 7841e10a957d4bceb2205632c49543af.ygk
777 p18i13847jgnl1s91kujqlh1t9c3.ygk
[hao#erp erp]# ls -l mve/
-rwxrwxrwx. 1 hao hao 63467455 Mar 10 21:38 7841e10a957d4bceb2205632c49543af.ygk
-rwxrwxrwx. 1 hao hao 111912448 Mar 10 21:46 p18i13847jgnl1s91kujqlh1t9c3.ygk
[root#erp erp]# smbd --version
Version 3.6.9-167.el6_5
[hao#erp erp]# ls -l
drwxrwxrwx. 2 hao hao 4096 Mar 11 09:42 mve
I Can copy all files in /opt/erp except in mve folder.
Please help, how to fix this problem. Please advice. Thank you.
This worked for me on Windows 7 when using CentOS 6.5.
http://rbgeek.wordpress.com/2012/05/25/how-to-install-samba-server-on-centos-6/
Slight changes to instructions..
The workgroup will need to change based on yours specifically (set value in /etc/samba/smb.conf).
Use \\192.168.x.x\ instead of \\centos on Windows.
You'll need to create the folders /samba and /samba/share and set permissions appropriately.
If your OS doesn't have nano (per the instructions), then install that before you begin... yum install nano
Run restart commands (2 of them) at the end twice, since the shutdown won't apply. Make sure you get OK on both.
I had a similar problem and it turned out to be related to the SELinux security context.
I had to run the command chcon -t samba_share_t /<path>/<to>/<share> -R.
Now i can create and change files in the shared folder.
I have 2 drives connected to the server both are 500GB.
drive 1 =/dev/sdc
drive 2 =/dev/sdb
I've partitioned the second drive /dev/sdb in 2 partitions having /dev/sdb1 & /dev/sdb2
What I was looking for is to mount 2 drives on one directory which is /home.
So I did this mount function
mount -l /dev/sdb /mnt/sdb
mount -l /dev/sdc1 /mnt/sdc1
mount -l /dev/sdc2 /backup
then mhddfs /mnt/sdb,/mnt/sdc1 /home -o allow_other
So 2 partitions are mounted to /home
And added this to /etc/ftab
/dev/sdb /mnt/sdb ext3 usrjquota=quota.user,jqfmt=vfsv0 1 1
/dev/sdc1 /mnt/sdc1 ext3 usrjquota=quota.user,jqfmt=vfsv0 1 1
/dev/sdc2 /backup ext4 usrjquota=quota.user,jqfmt=vfsv0 1 1
mhddfs#/mnt/sdb,/mnt/sdc1 /home fuse logfile=/var/log/mhddfs.log defaults,allow_other 0 0
My problem
first of all when reboot server the mhddfs is not automounted so I need to run the command manually through ssh "mhddfs /mnt/sdb,/mnt/sdc1 /home -o allow_other"
And sometimes when huge files are uploaded to /home directory it gets disconnected give this error message "`/home': Transport endpoint is not connected" so I have to umount and remount /home to resolve the problem.
Can you help me know what's wrong with my steps and what to do to resolve both problems.
I had the same issue. I wanted to extend my /home folder on my server by adding a second drive and chose to use mhddfs. I already had a whole harddrive entirely dedicated to my /home, the system being hosted on a separate drive - this has made things easier.
Here is how I proceeded, after my new harddisk was set up and formated:
I created two new mount points: /mnt/home1 and /mnt/home2
I edited /etc/fstab file to :
change my older harddisk moint point from /home to /mnt/home1
Set up my new harddisk mount point on /mnt/home2
Told mhddfs to merge /mnt/home1 and /mnt/home2 into /home
Here is the result in my etc/fstab:
UUID=f29aa9e5-5988-4603-9ecd-5c24dd804d94 /mnt/home1 ext4 defaults 0 2
UUID=e535c3fc-0842-4557-be85-55277912a058 /mnt/home2 ext4 defaults 0 2
mhddfs#/mnt/home1,/mnt/home2 /home fuse defaults,allow_other 0 0
Of course, you have to follow all these steps without restarting the machine (otherwise you will have no more /home directory).
It works pretty well. My older harddrive is now almost 100% full and my system began to write on the newer one, but practicaly speaking you don't even notice it. Everthing you see is a "normal" /home folder and mhddfs coordinates this in a totally transparent way.
I have tried with forcing fsck disk check on startup to make sure everything was ok - I set up the last parameter for mhddfs on /etc/fstab to "0" to make sure fsck does not create problem. Everything runs well, it seems pretty stable.