Showing posts with label mount. Show all posts
Showing posts with label mount. Show all posts

Tuesday, September 10, 2024

Mount cifs centos 7.9 server - windows share file

run command: 

sudo mount -t cifs -o username=shareusername,password=sharepassword //server/share /mnt


Ref: mount cifs

Thursday, October 7, 2021

mount NTFS with dual boot windows 10 and ubuntu 20.04 (R/W)

 1. run this command on Windows 10 with Administrator (If not run this ubuntu will not R/W file on mount drive)

powercfg /h off

Ref: ntfs-3g

2. Add command on file /etc/fstab 

# mount NTFS drive

UUID=483C6CC03C6CAB20 /media/user/drive_c ntfs-3g defaults,uid=1000,gid=1000,rw 0 1

UUID=3874B76D74B72D0E /media/user/drive_d ntfs-3g defaults,uid=1000,gid=1000,rw 0 1

* Create folder for mount Path file

mkdir -p /media/user/drive_c

mkdir -p /media/user/drive_d

* For check disk NTFS on ubuntu run command

sudo blkid

* Allow user to RW file

uid=1000,gid=1000,rw

 

Sunday, August 22, 2021

howto mont file NTFS in windows to Ubuntu 20.04.3 LTS

 I use multi OS in my notebook. I want to mount file NTFS from windows to Ubuntu.

1. Create file

sudo mkdir -p /media/user/drive_c

sudo mkdir -p /media/user/drive_d

sudo chown user:guser /media/user/* -R

2. check path location NTFS

sudo fdisk -l

Device              Start        End   Sectors   Size Type

/dev/nvme0n1p1       2048     206847    204800   100M EFI System

/dev/nvme0n1p2     206848     239615     32768    16M Microsoft reserved

/dev/nvme0n1p3     239616  168011775 167772160    80G Microsoft basic data

/dev/nvme0n1p4  168011776  285198335 117186560  55.9G Linux filesystem

/dev/nvme0n1p5  762908672  967706623 204797952  97.7G Microsoft basic data

/dev/nvme0n1p6  967708672  968757247   1048576   512M Windows recovery environme

/dev/nvme0n1p7  968757248  998117375  29360128    14G Windows recovery environme

/dev/nvme0n1p8  998117376 1000214527   2097152     1G Windows recovery environme

/dev/nvme0n1p9  285198336  300822527  15624192   7.5G Linux swap

/dev/nvme0n1p10 300822528  762908671 462086144 220.3G Linux filesystem

Partition table entries are not in disk order.

3. add command to file /etc/fstab
# mount NTFS drive
/dev/nvme0n1p3 /media/user/drive_c ntfs defaults,uid=1000,gid=1000,rw 0 0
/dev/nvme0n1p5 /media/user/drive_d ntfs defaults,uid=1000,gid=1000,rw 0 0

4. run command
sudo mount -a
or restart notebook.


Thursday, March 24, 2016

script test login linux domain

1.สร้างไฟล์สคริป login: testlogin.sh
------------------------------------start script--------------------------------
smbclient //192.168.1.99/netlogon -Uadmin%passwordadmin -c 'ls'  > login.txt
------------------------------------End script--------------------------------
คำอธิบาย

smbclient   = command
//192.168.1.99/netlogon = ip: domain server / Path
-Uadmin%passwordadmin = User: admin, %=ใส่พาสเวิร์ดของ admin ในตัวอย่างสมมุติเป็น passwordadmin
-c 'ls' = command
> ส่งผลการทดสอบ login ไปในไฟล์ login.txt

2. สร้างไฟล์สำหรับส่งเมล sentmail.sh
---------------------------------Start script----------------------------------
mail -s "Subject test logindomain" < login.txt  groupmail1@email.com email2@email.com
---------------------------------End script-----------------------------------
คำอธิบาย

mail -s "Subject test logindomain"  = ส่งเมลด้วย subject "Subject test logindomain"
< login.txt = ดึงไฟล์ login.txt ส่งเข้าไปในเมล
email ใส่รายชื่อเมลที่เราต้องการให้สคริปส่งเมลไป

3. สร้าง crontab เพื่อให้สคริปทำงานและส่งเมลตามเวลาที่เรากำหนด
crontab -e   = สำหรับ debian
vim /etc/crontab  = สำหรับ CentOS

----------------------crontab----------------------------
00 */1 * * * root /root/folder/testlogin.sh    ->เทส login ทุก 1 ชม.
05 */1 * * * root /root/folder/sentmail.sh    -> แล้วส่งเมลทุก 1 ชม. 5 น.
*/05 * * * * sh /roo/chmod.sh                      Every 5 Minite
----------------------End crontab-----------------------

4. Error : tree connect failed: NT_STATUS_BAD_NETWORK_NAME
วิธีแก้ไข
4.1 เข้าไปเช็คไฟล์ smb.conf มีการกำหนด share file: netlogon ไว้ไหม
4.2 หากกำหนดไว้แล้วให้เช็คดูตาม Path ดัวกล่าว มีการสร้าง Folder: netlogon ไว้หรือไม่?
4.3 หากไม่พบให้ทำการสร้าง และกำหนด permission เป็น 755 ดังตัวอย่างต่อไปนี้
   
      mkdir /var/lib/samba/netlogon
      chmod 755 /var/lib/samba/netlogon
      ls -lF /var/lib/samba

4.4 ทดสอบรันสคริป testlogin.sh หรือก็อปปี้คำสั่งไปรันทดสอบบน terminal จะพบว่าเทส login ได้สำเร็จ

อ้างอิง
ubuntuforums.org

5. การ Mount domain
5.1 mkdir /medial/user/mydomain
5.2 chmode user:user /media/user/mydomain
5.3 run command

mount -t cifs //192.168.1.99/netlogon -o username=admin,password=passwordadmin /media/user/mydomain

อ้างอิง
sharadchhetri.com



Wednesday, March 16, 2016

Remote ssh โดยกุญแจเข้ารหัส ไม่ต้องถาม password

การทำสคริป copy file ผ่าน ssh โดยกุญแจเข้ารหัส (ไม่ต้องถาม password)


วัตถุประสงค์
            ต้องการทำสคริปเพื่อก็อปปี้ไฟล์จากเครื่อง Server ไปเก็บไว้ยัง Backup Server ถ้าเราทำแบบแมนนวล เวลารันคำสคิป ก็ต้องคีย์ password ssh แต่ถ้าไม่อยากคีย์ก็ทำเป็น Text file ไว้แล้วให้สคิปไปเช็ค password กับ Text file นั้น
            การทำแบบนี้มีโอกาสโดนขโมยอ่าน password ได้ ดังนั้น จึงใช้วิธีการ Encryption password ไว้ ในรูปแบบกุญแจ 2 ลูก ลูกนึงวางไว้ที่เครื่อง Server ต้นทาง และอีกลูกนึงวางไว้ที่ Backup Server

วิธีการ
1. Key Encryption การทำกุญแจเข้ารหัสพาสเวิร์ด มีขั้นตอนดังนี้

เครื่อง Server

ใช้รูปแบบคำสั่ง ด้านล่าง
#ssh-keygen -t rsa -b 4096  ค่าปกติ 2048 bit

จะมี 2 ไฟล์  Generate ขึ้นมา ที่ /root/.ssh/ ดูภาพด้านล่าง



id_rsa
id_rsa.pub

เสร็จแล้วให้ก็อปปี้ไฟล์ id_rsa.pub ไปยังเครื่อง Backup Server ด้วยคำสั่ง
scp id_rsa.pub user@192.168.x.x:/path/backup

เครื่อง Backup Server

เข้าไปยัง path ที่เก็บไฟล์ id_rsa.pub แล้ว convert ไฟล์ไปยัง authorized_keys ที่ /root/.ssh/ ด้วยคำสั่ง
ต่อไปนี้

cp authorized_keys authorized_keys.bak ก็อปปี้ไฟล์กุญแจไว้ก่อน

cat id_rsa.pub >> /root/.ssh/authorized_keys

cat authorized_keys เพื่อดูคีย์ที่เราเพิ่มเข้าไป มีการเข้ารหัสไว้

ทดสอบใช้งาน

กลับไปที่เครื่อง Server แล้วลองก็อปปี้ไฟล์ ไปเก็บไว้ยัง Backup Server ด้วยคำสั่งเดิมอีกคร้้ง

scp test.txt user@192.168.x.x:/path/backup

วิธีการส่งคำสั่งไปรันที่เครืองรีโมทย์
ssh 192.168.10.xx "command 1 && command2"
ssh 192.168.10.xx "update && date"

จะเห็นว่าไม่มีการถาม password เหมือนตอนแรก

2. ทำสคริปเพื่อให้ก็อปปี้ไฟล์จากเครื่อง Server ไปยังเครื่อง Backup Server ดังนี้

crontab -e
ใส่สคริปให้ทำงาน เวลา 20:00 น. ของทุกวัน

0 20 * * *      scp -r /etc/postfix user@192.168.xx.xx:/pathe/backup

เรื่องที่เกี่ยวข้อง
1. คำสั่ง scp
2. Key Encryption




Sunday, August 9, 2015

mount file iso on linux

  1. Create a directory to serve as the mount location:
    sudo mkdir /media/iso
    
  2. Mount the ISO in the target directory:
    sudo mount -o loop path/to/iso/file/YOUR_ISO_FILE.ISO /media/iso
    
  3. Unmount the ISO:
    sudo umount /media/iso

Monday, August 3, 2015

Mount disk volume (Centos) on linux debian

วิธีทำ
1. เปิด Terminal ใช้คำสั่ง vgdisplay ตรวจสอบ Disk volume

termcb:~ # vgdisplay
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 27.84 GB
PE Size 32.00 MB
Total PE 891
Alloc PE / Size 890 / 27.81 GB
Free PE / Size 1 / 32.00 MB
VG UUID ryYRi4-mXOd-XFaW-4xnR-h1cl-hphh-5QQnlM

2. ใช้คำสั่ง lvscan เช็คสถานะ Hard disk

termcb:~ # lvscan
inactive '/dev/VolGroup00/LogVol00' [26.06 GB] inherit
inactive '/dev/VolGroup00/LogVol01' [1.75 GB] inherit

3. ใช้คำสั่ง ก่อน Mount disk

modprobe dm-mod
vgchange -ay

4. ใช้คำสั่งในข้อ 2. เช็คสถาน Hard disk อีกครั้ง จะพบว่า Disk Active

termcb:~ # lvscan
ACTIVE '/dev/VolGroup00/LogVol00' [26.06 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol01' [1.75 GB] inherit

5. Mount hard disk เพื่อใช้งาน


mount /dev/VolGroup00/LogVol00 /mount/point


Ref:   
http://pissedoffadmins.com/os/mount-unknown-filesystem-type-lvm2_member.html

Wednesday, January 1, 2014

mont /etc/fstab on ubuntu 13.04

Add scrip mount network For ubuntu 13.04

-----------------/etc/fstab-----------------
//192.168.x.xx/Market /media/Market    cifs user=user01,passwd=user001,uid=1000,gid=1000
--------------////------------------------------

------------------------------------------------------------
ใช้คำสั่ง dmesg | tail เพื่อตรวจสอบหาปัญหาทำไมไม่สามารถ mount path share file windows 2000 with CentOs 8 จะได้ Error: No dialect specified on mount. Default has changed to a more secure dialect, SMB2.1 or later (e.g. SMB3), from CIFS (SMB1). To use the less secure SMB1 dialect to access old servers which do not support SMB3 (or SMB2.1) specify vers=1.0 on mount.

การทำ Mount Drive ในกรณีที่เครื่อง Windows 2000 SMBv1 แต่เครื่อง Linux Server รุ่นใหม่(SMBv2,3) ไม่ Support SMBv1 ซึ่งเป็น Version เก่า

Allowed SMB protocol version values are:
  • 1.0 - The classic CIFS/SMBv1 protocol. This was the default.
  • 2.0 - The SMBv2.002 protocol. This was initially introduced in Windows Vista Service Pack 1, and Windows Server 2008. Note that the initial release version of Windows Vista spoke a slightly different dialect (2.000) that is not supported.
  • 2.1 - The SMBv2.1 protocol that was introduced in Microsoft Windows 7 and Windows Server 2008R2.
  • 3.0 - The SMBv3.0 protocol that was introduced in Microsoft Windows 8 and Windows Server 2012.

แก้ไข /etc/fstab

//172.16.0.xx/Sharefile /mnt/sharefile cifs user,uid=1000,rw,suid,username=user03,password=user003,iocharset=utf8,vers=1.0 0 0

เสร็จแล้วรันคำสั่ง
mount -a
ยกเลิกการ mount
umount /mnt/sharefie

-------------------------------------------------------------------------

การสร้างสคริป Mount Drive แบบอัตโนมัติ

vim /root/mapdrive.sh
-----------------------Start Script---------------------------------
mount -o username=user,password=xxxx,uid=1000,gid=1000 //192.168.1.10/public/share /media/support/share

------------------------End script----------------------------------

Run Script

sudo vim /etc/rc.local --> แอดสคริปให้ทำงานทุกคร้้งตอนเปิดเครื่อง
---------------------------------
# By default this script does nothing.
/root/mapdrive.sh
----------------------------------------

Monday, April 8, 2013

Scrip Map network drive on ubuntu


For ubuntu 10.xx - 12.04
//192.168.4.xx/market  /media/market  cifs    username=center,password=xxx001,iocharset=utf8,codepage=unicode,unicode       0       0

For ubuntu 12.04 Kernel 3.6.0
install packet smbfs
#aptitude install smbfs
edit #vim /etc/fstab
.
.
//192.168.4.xx/market  /media/market  cifs    username=center,password=xx001,iocharset=utf8,uid=1000,gid=1000       0       0

**uid=1000 check on /etc/passwd
**gid=1000 check on /etc/group

command map

#mount -o username=mxx,password=mxxx //192.168.xx.25/share folder /media/mail

Create file Credentails

1. Create Folder on Client
#mkdir /home/user/Sharefile

2. create file passwd credentail

#echo “username=samba_username” > /home/user/Sharefile/.smbcredentials
#echo “password=password_username” > /home/user/Sharefile/.smbcredentials
#chmod 600 /home/user/Sharefile/.smbcredentials

3. Edit file /etc/fstab
add new line

#//192.168.0.xx/downloads        /home/user/Sharefile       cifs    uid=1000,gid=1000,credentials=/home/user/Sharefile/.smbcredentials,defaults        0       0

4.Run mapdrive
#mount //192.168.0.xx/downloads
or
#mount -a

umount
#umount Sharefile


Ref.
techsuii.com