0

I have a script to format a drive, set permissions (777), copy a file, change permissions (555) and unmount and eject the drive for cinema DCPs. Currently everything is working but I'm getting an issue with chmod. Files copy from source to target drive with proper permissions so I'm not sure what the error is. Script and output below:

Script

#! /bin/bash

#Format Drive

sudo umount /dev/sda1 
sudo parted -s /dev/sda mktable msdos 
sudo parted /dev/sda mkpart primary ext3 1 100% 
sudo wipefs -a /dev/sda1 
sudo mkfs.ext3 -I 128 -L "DCP" /dev/sda1

#Update /etc/fstab

sudo mount -a

#Mount Drive

sudo mount /dev/sda1 /media/mynamehere/

#Set Permissions

sudo chmod -R 777 /media/mynamehere/DCP

#Copy Files to Target Drive

sudo rsync -av ~/Desktop/Source_Folder/ /media/mynamehere/DCP/

#Set Permissions

sudo chmod -R 555 /media/mynamehere/DCP

#Unmount Disk

sudo umount /dev/sda1

#Eject Disk

sudo eject /dev/sda1

Output

Information: You may need to update /etc/fstab.

mke2fs 1.43.5 (04-Aug-2017)                                               
Creating filesystem with 3931904 4k blocks and 983040 inodes
Filesystem UUID: 68e0a893-3fe8-4daf-8ba0-3d5a285903fc
Superblock backups stored on blocks: 
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done   

chmod: cannot access '/media/mynamehere/DCP': No such file or directory

sending incremental file list

created directory /media/mynamehere/DCP
./
ASSETMAP
CPL_DCP_SHR-2D_F-185_EN_51_2K_20180125_IOP_OV_a3b962d5-4e8d-46.xml
DCP_SHR-2D_F-185_EN_51_2K_20180125_IOP_OV_2707c99f-e757-44_j2c.mxf
DCP_SHR-2D_F-185_EN_51_2K_20180125_IOP_OV_fb719829-110f-4b_pcm.mxf
PKL_DCP_SHR-2D_F-185_EN_51_2K_20180125_IOP_OV_608bffb5-7d2d-49.xml
VOLINDEX

sent 1,117,023,702 bytes  received 185 bytes  248,227,530.44 bytes/sec
total size is 1,116,750,369  speedup is 1.00
3

From your output:

chmod: cannot access '/media/mynamehere/DCP': No such file or directory

Quite simply, the directory DCP does not exist until after you create it (using rsync, in the next line).

Since you are running every command as root, running chmod 777 beforehand should not make a difference anyway (as witnessed by the fact that the rest of the script runs successfully).

  • cheers! Thanks for the help. Will update and test. – tduff Feb 9 '18 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.